From dff64a339de8275105963159a9391a2685cfd538 Mon Sep 17 00:00:00 2001 From: Manvender Singh Rathore Date: Sun, 18 Nov 2018 14:56:59 +0530 Subject: [PATCH] Quick Sort Complexity Table (#22056) * Quick Sort Complexity Table --- .../algorithms/sorting-algorithms/quick-sort/index.md | 9 ++++++++- 1 file changed, 8 insertions(+), 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 9743d8deba..ee67ddccbd 100644 --- a/guide/english/algorithms/sorting-algorithms/quick-sort/index.md +++ b/guide/english/algorithms/sorting-algorithms/quick-sort/index.md @@ -128,7 +128,14 @@ int main() return 0; } ``` -The space complexity of quick sort is O(n). This is an improvement over other divide and conquer sorting algorithms, which take O(nlong(n)) space. Quick sort achieves this by changing the order of elements within the given array. Compare this with the merge sort algorithm which creates 2 arrays, each length n/2, in each function call. + +## Complexity + +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Quick sort** | n log(n) | n log(n) | n2 | log(n) | No | Quicksort is usually done in-place with O(log(n)) stack space | + +The space complexity of quick sort is O(n). This is an improvement over other divide and conquer sorting algorithms, which take O(n log(n)) space. #### More Information: