Implement the (joke) "sleep sort": schedule each number with a delay proportional to its value and collect them as the timers fire. Explain why it is not a real sorting algorithm.
The timer queue does the sorting, by due time. It only works for small non-negative numbers spaced far enough apart, and its running time depends on the largest value – a fun way to show that timers fire in due-time order.
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!
We use Google Analytics cookies to see how LearnFrenzy is used and make it better, and Google AdSense to keep it free.
No analytics or ad cookies are set until you accept. Privacy Policy
·
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!