We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f3771b1 commit 4d6a5a1Copy full SHA for 4d6a5a1
Quick Sort/quick_sort.cpp
@@ -0,0 +1,13 @@
1
+void QuickSort(vector<int>& arr, int left, int right) {
2
+ int x = arr[(left + right) / 2];
3
+ int i = left, j = right - 1;
4
+ while (i <= j)
5
+ {
6
+ while (arr[i] < x) i++;
7
+ while (arr[j] > x) j--;
8
+ if (i <= j)
9
+ swap(arr[i++], arr[j--]);
10
+ }
11
+ if (left < j) QuickSort(arr, left, j + 1);
12
+ if (i < right) QuickSort(arr, i, right);
13
+}
0 commit comments