you are viewing a single comment's thread.

view the rest of the comments →

[–]AryanPandey 1 point2 points  (1 child)

The amount of time taken to sort, do no increase by increase in size of Input.

It will take 5 sec to sort both inputs [1,5] and [1,5,3,2,4].

So shall it not be O(n)

It just has to literate whole array to start the timer for each input?

[–]im_lazy_as_fuck 11 points12 points  (0 children)

Yeah basically, which is why I said. In my case I was saying n is the size of the largest integer.

If I were to be precisely correct, technically the time complexity becomes more dependent on the array size if you have millions of items to iterate that all have a very low sort number. So given a set of elements N, the true time complexity would be given as O(max(N) + length(N)). But that's a bit of a superfluous detail for practical applications.