using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AlgorithmTest
{
class QuickSort
{
private int Partition ( int[] arr, int p, int r )
{
int x = arr[r];
int j = p -1;
for (int i = p; i < r; i++)
{
if (arr[i] <= x)
{
j++;
int temp1 = arr[j];
arr[j] = arr[i];
arr[i] = temp1;
}
}
int temp2 = arr[++j];
arr[j] = x;
arr[r] = temp2;
return j;
}
public void Quick_Sort ( int[] arr, int p, int r )
{
if (p < r)
{
int q = Partition(arr, p, r);
Quick_Sort(arr, p, q-1);
Quick_Sort(arr, q + 1, r);
}
}
}
}