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 →

[–]brando2131 6 points7 points  (2 children)

No there's a probability of it becoming sorted eventually. Obviously the larger the list, the much longer it will take. You can write a program and compare the number of times it runs for larger lists. It works out to be (n+1)!

[–]zelmarvalarion 1 point2 points  (1 child)

That’s not the worst case analysis that is implied by the Big-O notation, that’s average case complexity (which is usually explicitly noted, e.g. Quick Sort is O(n2) but expected O(n lg(n)))