File tree Expand file tree Collapse file tree 4 files changed +4
-8
lines changed
src/algorithms/sorting/quickSort Expand file tree Collapse file tree 4 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,7 @@ especially when the array is already sorted or has a specific pattern. This is b
38
38
might create highly unbalanced sub-arrays, causing the algorithm to degrade to O(n^2) time complexity.
39
39
40
40
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
43
42
44
43
## Notes
45
44
Original file line number Diff line number Diff line change 38
38
* duplicates in the array leads to extremely unbalanced partitioning, leading to a O(n^2) time complexity.
39
39
*
40
40
* 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
43
42
*/
44
43
45
44
public class QuickSort {
Original file line number Diff line number Diff line change 29
29
* enter an infinite loop of repeating pivot selection.
30
30
*
31
31
* 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
34
33
*/
35
34
36
35
public class QuickSort {
Original file line number Diff line number Diff line change 22
22
* - Best case: O(nlogn)
23
23
*
24
24
* 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
27
26
*/
28
27
29
28
public class QuickSort {
You can’t perform that action at this time.
0 commit comments