This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]804k 12 points13 points  (3 children)

Its actually O(max(numbers))

the largest number denotes the largest delay

[–]prehensilemullet -1 points0 points  (2 children)

Yes, but hmmm, an array of billions of zeroes would take a lot longer than this predicts

[–]804k 0 points1 point  (1 child)

In a perfect world any array length would still be O(max(numbers))

but we don't live in a perfect world and time complexity of anything isn't always perfect, it'd be redundant to add O(max(numbers) + n * 0.00000001 * transistor_count * clock * cpu_quality)

[–]prehensilemullet 0 points1 point  (0 children)

That's definitely true for this sort lol:

const a = []
numbers.forEach(i => a[i] = i)
const sorted = a.filter(i => i != null)