Is there a sorting algorithm that can sort n distinct integers from 3 to 4n in O(n) time?
I have been trying this problem for an hour now and I have no idea what to do.
Any tips?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all, comparison based sorting algorithms cannot do better than a worst case time complexity of O(nlogn), so don’t use any of them.
As it is homework, look at:
Hope this helps.