From 0884ada63e7337a59051ed91ab7da9af616399ff Mon Sep 17 00:00:00 2001 From: Ivan Johnson Date: Sat, 30 Jun 2018 10:12:33 -0500 Subject: [PATCH] Correct bogosort's best case runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- chapters/sorting_searching/bogo/bogo_sort.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/sorting_searching/bogo/bogo_sort.md b/chapters/sorting_searching/bogo/bogo_sort.md index ca5c77516..0c11db4af 100644 --- a/chapters/sorting_searching/bogo/bogo_sort.md +++ b/chapters/sorting_searching/bogo/bogo_sort.md @@ -8,7 +8,7 @@ imagine you have an array of $$n$$ elements that you want sorted. 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. If they are not in order, just shuffle everything again. And then again. And again. -In the best case, this algorithm runs with a complexity of $$\Omega(1)$$, and in the worst, $$\mathcal{O}(\infty)$$. +In the best case, this algorithm runs with a complexity of $$\Omega(n)$$, and in the worst, $$\mathcal{O}(\infty)$$. In code, it looks something like this: