Skip to content

Commit 6a000b1

Browse files
committed
Edited space complexity
1 parent 0fd5436 commit 6a000b1

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

src/algorithms/sorting/quickSort/hoares/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ especially when the array is already sorted or has a specific pattern. This is b
3838
might create highly unbalanced sub-arrays, causing the algorithm to degrade to O(n^2) time complexity.
3939

4040
Space:
41-
- O(logn) as the partitioning is done in-place so each partitioning takes O(1) space but depth of QuickSort recursion
42-
is logn, therefore logn * O(1) = O(logn)
41+
- O(1) excluding memory allocated to the call stack, since partitioning is done in-place
4342

4443
## Notes
4544

src/algorithms/sorting/quickSort/lomuto/QuickSort.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
* duplicates in the array leads to extremely unbalanced partitioning, leading to a O(n^2) time complexity.
3939
*
4040
* Space:
41-
* - O(logn) as the partitioning is done in-place so each partitioning takes O(1) space but depth of QuickSort
42-
* recursion is logn, therefore logn * O(1) = O(logn)
41+
* - O(1) excluding memory allocated to the call stack, since partitioning is done in-place
4342
*/
4443

4544
public class QuickSort {

src/algorithms/sorting/quickSort/paranoid/QuickSort.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
* enter an infinite loop of repeating pivot selection.
3030
*
3131
* Space:
32-
* - O(logn) as the partitioning is done in-place so each partitioning takes O(1) space but depth of QuickSort
33-
* recursion is logn, therefore logn * O(1) = O(logn)
32+
* - O(1) excluding memory allocated to the call stack, since partitioning is done in-place
3433
*/
3534

3635
public class QuickSort {

src/algorithms/sorting/quickSort/threeWayPartitioning/QuickSort.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
* - Best case: O(nlogn)
2323
*
2424
* Space:
25-
* - O(logn) as the partitioning is done in-place so each partitioning takes O(1) space but depth of QuickSort
26-
* recursion is logn, therefore logn * O(1) = O(logn)
25+
* - O(1) excluding memory allocated to the call stack, since partitioning is done in-place
2726
*/
2827

2928
public class QuickSort {

0 commit comments

Comments
 (0)