Re:Trolling homework questions - sorting
by jeremymcanally on Friday December 27, 2013 @08:32PM
(#6973465)
No one suggested sleep sort? That's the ultimate trolling-but-almost-legitimate sorting algorithm. :)
[ Parent
| on HN ]
Re:Trolling homework questions - sorting
by mihai_ionic on Friday December 27, 2013 @08:37PM
(#6973475)
And it even has the best time bound you can get for a comparison based sort. Most OS schedulers would use a heap/priority queue internally for timers, which makes sleep sort O(n log n).
Re:Trolling homework questions - sorting
by gizmo686 on Friday December 27, 2013 @09:26PM
(#6973580)
wouldn't sleep sort be O(k), where k is the largest element to be sorted? (Assuming the clock and scheduler are precise enough to achieve the correct answer the first attempt).
Re:Trolling homework questions - sorting
by mihai_ionic on Friday December 27, 2013 @09:35PM
(#6973612)
I would't really count time passing as an operation, since other programs are able to run during that time.
Re:Trolling homework questions - sorting
by gweinberg on Saturday December 28, 2013 @12:51PM
(#6975560)
You could keep it linear by first going through the list to find the max, then scaling down.
Re:Trolling homework questions - sorting
by Moto7451 on Saturday December 28, 2013 @04:53AM
(#6974569)
I noticed this myself and decided to write a glorious example in Objective C:
Re:Trolling homework questions - sorting
by justinhj on Saturday December 28, 2013 @12:31PM
(#6975491)
I wrote a version in Go http://codegolf.stackexchange.com/a/16468/11452
Re:Trolling homework questions - sorting
by pedramnegahdar on Saturday December 28, 2013 @05:44AM
(#6974664)
I just found my new favorite sorting algorithm.