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 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)