3 ms·
I really like sleep sort because it trades (fundamentally) cycles and memory for time. In theory you could do this in hardware. Hardware timers are pretty triv
by thehappypm 5y ago
I really like sleep sort because it trades (fundamentally) cycles and memory for time.
In theory you could do this in hardware. Hardware timers are pretty trivial, you could imagine a hardware chip that accepts a number, then writes the value to the next free slot in an array when the time has elapsed. As timers go off, the array fills up. Obviously you need to handle collisions and whatnot but nothing in this screams that you need to go O(n^2).
- Sharlin 5y agoYou need n separate programmable timers, though. If you only have a constant number of timers, then you’re back to implementing something approaching a priority queue to schedule the events (possibly in hardware if you want)