QuickSort
void QuickSort(int *arr, int size) {
if (size <= 1) return;
QuickSortRecursive(arr, 0, size - 1);
}
void QuickSortRecursive(int *arr, int start, int end) {
if (start >= end) return;
int pivotIndex = Partition(arr, start, end);
QuickSortRecursive(arr, start, pivotIndex - 1);
QuickSortRecursive(arr, pivotIndex + 1, end);
}
int Partition(int *arr, int start, int end) {
int pivot = arr[start];
int i = start + 1;
for (int j = start + 1; j <= end; j++) {
if (arr[j] < pivot) {
std::swap(arr[i], arr[j]);
i++;
}
}
std::swap(arr[start], arr[i - 1]);
return i - 1;
}