Skip to content

Commit 5710e2b

Browse files
Ivan-Johnsonleios
authored andcommitted
Correct bogosort's best case runtime (#186)
Bogosort's best case runtime is not constant, because even if the array is already sorted, it still has to perform Θ(n) operations to verify that each of the n elements are in order.
1 parent c481bf9 commit 5710e2b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

chapters/sorting_searching/bogo/bogo_sort.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ imagine you have an array of $$n$$ elements that you want sorted.
88
One way to do it is to shuffle the array at random and hope that all the elements will be magically in order after shuffling.
99
If they are not in order, just shuffle everything again.
1010
And then again. And again.
11-
In the best case, this algorithm runs with a complexity of $$\Omega(1)$$, and in the worst, $$\mathcal{O}(\infty)$$.
11+
In the best case, this algorithm runs with a complexity of $$\Omega(n)$$, and in the worst, $$\mathcal{O}(\infty)$$.
1212

1313
In code, it looks something like this:
1414

0 commit comments

Comments
 (0)