From ad6eed1ef36a33acb339586c5c88a37618dce0ac Mon Sep 17 00:00:00 2001 From: Ha Anh Nguyen Date: Wed, 31 Oct 2018 17:12:17 +0200 Subject: [PATCH] Add explanation about various time complexity (#20565) Explaining the why time complexity of quick sort varies --- guide/english/algorithms/sorting-algorithms/quick-sort/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/english/algorithms/sorting-algorithms/quick-sort/index.md b/guide/english/algorithms/sorting-algorithms/quick-sort/index.md index 5e8cc13cfb..9743d8deba 100644 --- a/guide/english/algorithms/sorting-algorithms/quick-sort/index.md +++ b/guide/english/algorithms/sorting-algorithms/quick-sort/index.md @@ -3,7 +3,7 @@ title: Quick Sort --- ## Quick Sort -Quick sort is an efficient divide and conquer sorting algorithm. Average case time complexity of Quick Sort is O(nlog(n)) with worst case time complexity being O(n^2). +Quick sort is an efficient divide and conquer sorting algorithm. Average case time complexity of Quick Sort is O(nlog(n)) with worst case time complexity being O(n^2) depending on the selection of the pivot element, which divides the current array into two sub arrays. For instance, the time complexity of Quick Sort is approximately O(nlog(n)) when the selection of pivot divides original array into two nearly equal sized sub arrays. On the other hand, if the algorithm, which selects of pivot element of the input arrays, consistently outputs 2 sub arrays with a large difference in terms of array sizes, quick sort algorithm can achieve the worst case time complexity of O(n^2). The steps involved in Quick Sort are: - Choose an element to serve as a pivot, in this case, the last element of the array is the pivot.