Post

That sounds like an environment problem The algorithm theoretically still satisfies linear time

0 reposts0 likes

*dull mode on* No, it doesn't. As stated in comments above the time complexity of the sleepsort depends not on the quantity of the elements in input data, but on elements' values. Taking the O for the sleep(n) itself as O(n) we get the n=MAXn(Vi) for the best case (enough CPUs) and ...

...n=SUMn(Vi) for the worst case - on a single core. It actually makes big-O notation useless here, since it cannot show how the algorithm scales on elements quantity. Actually, it's impossible to find any asymptotic function for such case, since the input data values unknown

PS. It's better keep in mind the "time" in "big-O time complexity" isn't about a time in seconds or any time units, but about the operations/steps quantity. And not the absolute quantity but a function, which would asymptotically close to the quantity. It's about scalability, not the absolute time

In addition, I would not consider sleepsort as a sorting algorithm at all, since it's defined only for natural numbers. If you get an abstract data element with only comparator defined, you will have to associate an ordinal number to each element first, what implies ... sorting them.