| | |
Question: Linear Time Sorting Problem
Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
Thread Solved |
•
•
Join Date: Mar 2007
Posts: 9
Reputation:
Solved Threads: 0
Hello, I have been asked to provide an algorithm for the following:
You are given an array of length N, which contains values in the range from 0 to (N^2) - 1. You are to sort it in O(N) time.
I have been unable to find any way to do it, due to the lack of a "hard" upper bound on the input range (Which varies with the size of input).
I'll be happy to hear ideas for anyone who can offer help. Thanks !
You are given an array of length N, which contains values in the range from 0 to (N^2) - 1. You are to sort it in O(N) time.
I have been unable to find any way to do it, due to the lack of a "hard" upper bound on the input range (Which varies with the size of input).
I'll be happy to hear ideas for anyone who can offer help. Thanks !
•
•
Join Date: Mar 2007
Posts: 9
Reputation:
Solved Threads: 0
While I thank you for the reply - I already read the wikipedia entry for that, twice. I also spent a few hours on google, and reading "Introduction To Algorithms" (One of the authors is Cormen, another is Rivest, another is Stein, I don't recall the last one).
Any other ideas folks ?
Any other ideas folks ?
Last edited by Direwolf007; Apr 1st, 2007 at 9:57 am.
>> You are given an array of length N, which contains values in the range from 0 to (N^2) - 1. You are to sort it in O(N) time.
2 questions to understand the question:
1. Why does the range of value matter? (size/range of value would have no impact on the order of algorithm from what I know)
2. When you say "in O(N) time" do you mean it's an algorithm of order N or you really mean some number of mili/micro/seconds.. ?
2 questions to understand the question:
1. Why does the range of value matter? (size/range of value would have no impact on the order of algorithm from what I know)
2. When you say "in O(N) time" do you mean it's an algorithm of order N or you really mean some number of mili/micro/seconds.. ?
1. It does affect algorithm runtime in several cases, especially when dealing with non-comparison based sorts (since it's proven that comparision based sorts cannot be guaranteed to run in better than O(n log n) time, they don't make the cut for this problem). Look at some of the sorts already mentioned in this thread.
2. Linear time with respect to the length of the input.
2. Linear time with respect to the length of the input.
Have you tried out SmoothSort ?
Its best case is O(n) and worst case is O(n log(n)) with the obvious downfall of difficult to implement.
Its best case is O(n) and worst case is O(n log(n)) with the obvious downfall of difficult to implement.
Last edited by ~s.o.s~; Apr 3rd, 2007 at 4:11 pm.
I don't accept change; I don't deserve to live.
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
![]() |
Other Threads in the Computer Science Forum
- Previous Thread: Using flex and bison
- Next Thread: Instructor's manual
Views: 6547 | Replies: 29
| Thread Tools | Search this Thread |
Tag cloud for Computer Science
ai algorithm algorithms amazon assignment assignments automata battery bigbrother binary bizarre blogging bomb business cern clueless codebreaker computer computers computerscience computertrackingsoftware connect conversion dataintepretation development dfa dissertation dissertations dissertationthesis dissertationtopic ebook energy extensions floatingpoint foreclosure fuel gadgets geeks givemetehcodez government graphics hardware history homeowners homework homeworkhelp humor ibm idea ideas internet iphone itcontracts jobs kindle laser laws lazy linkbait lsmeans mainframes marketing mobileapplication msaccess nano netbeans networking news os p2p parser piratebay principles programming rasterizer research sam-being-cute sas science security sex spoonfeeding spying sql stephenfry student study supercomputer supercomputing syntactic technology textfield tree turing turingtest two'scompliment uk virus warehouse ww2






