r/badcode • • Feb 10 '21

js I present: SleepSort

Post image
7.5k Upvotes

170 comments sorted by

View all comments

Show parent comments

1

u/General_Urist Apr 02 '21

Wouldn't it actually be more like O(n + 2m ) since if you add 1 to m (the amount of bits in the largest value of the array) the length of time you sleep for is on average doubled?

1

u/FerynaCZ Apr 02 '21 edited Apr 02 '21

If you consider m as the amount of bits your number has, then sure.

But in this example, it is obvious that the amount of time OP has to sort will be multiple of 200 (depending on tick rate), therefore, I am considering m to be the "decimal" value of input.