You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: leetcode/medium/912_sort_an_array.md
+2-31
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# 912. Sort an Array
2
2
3
-
## Quick Sort
3
+
## Quick Sort In-Place
4
4
5
5
- Runtime: O(Nlog(N)), worst case O(N^2)
6
6
- Space: O(log(N))
@@ -17,38 +17,9 @@ The pivot is now in the correct place.
17
17
We then partition the array in two halves and call a recursion on each half, they will be figuring out where the correct placement of the next pivot should be.
18
18
This is where the log(N) comes into play, since each time we call the recursion, the array is half of what it use to be.
19
19
20
-
If the pivot is always selected to be the smallest number of the array, we can have a worst case scenario of O(N^2).
20
+
If the pivot is always selected to be the largest number of the array, we can have a worst case scenario of O(N^2).
0 commit comments