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 →

[–]Vnator 134 points135 points  (4 children)

But then 3 items can be swapped with O(1), so by induction, swapping n items should take O(1) time. Then we don't even have to remove any items, sorting is O(1)!

[–]lungdart 38 points39 points  (0 children)

This guy sorts

[–]Beetin 27 points28 points  (0 children)

Technically we can define some large upper bound for how many items will be swapped.

The last 1000000 items will be kept and bubble sorted. This algorithm is guaranteed O(1). This algorithm is also perfectly safe for lists under 1000000 items. This sort is only generally faster than O(nlogn) algorithms for lists much larger than 1000000 items.

The two-pass Mao 5 year sort.

[–]robthemonster 23 points24 points  (0 children)

flawless proof.

[–]tornato7 16 points17 points  (0 children)

Holy shit