Here's the code for quick sort
public class QuickSort
{
int partition(int arrNum[], int low, int high)
{
int pivot = arrNum[high];
int a = (low - 1);
for(int b = low; b < high; b++)
{
if(arrNum[b] <= pivot)
{
a++;
int temp = arrNum[a];
arrNum[a] = arrNum[b];
arrNum[b] = temp;
}
}
int temp = arrNum[a + 1];
arrNum[a + 1] = arrNum[high];
arrNum[high] = temp;
return a + 1;
}
void sortNumber(int arr[], int low, int high)
{
if(low < high)
{
int part = partition(arr, low, high);
sortNumber(arr, low, part - 1);
sortNumber(arr, part + 1, high);
}
}
static void printingArray(int arr[])
{
int num = arr.length;
for(int a = 0; a < num; ++a)
System.out.print(arr[a] + " ");
System.out.println();
}
public static void main(String[] args)
{
int arr[] = {33, 36, 63, 34, 45, 78};
int n = arr.length;
QuickSort qs = new QuickSort();
qs.sortNumber(arr, 0, n - 1);
System.out.println("Quicksort sorted array : ");
printingArray(arr);
}
}