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
3838might create highly unbalanced sub-arrays, causing the algorithm to degrade to O(n^2) time complexity.
3939
4040Space:
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
Original file line number Diff line number Diff line change 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
4544public class QuickSort {
Original file line number Diff line number Diff line change 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
3635public class QuickSort {
Original file line number Diff line number Diff line change 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
2928public class QuickSort {
You can’t perform that action at this time.
0 commit comments