diff --git a/sorting/QuickSort.java b/sorting/QuickSort.java new file mode 100644 index 0000000..736af0a --- /dev/null +++ b/sorting/QuickSort.java @@ -0,0 +1,30 @@ +/** + * Java implementation of quick sort + * + * @author Sandali Samarawickrama + */ + +class QuickSort +{ + /* This function takes last element as pivot, + places the pivot element at its correct + position in sorted array, and places all + smaller (smaller than pivot) to left of + pivot and all greater elements to right + of pivot */ + int partition(int arr[], int low, int high) + { + int pivot = arr[high]; + int i = (low-1); + for (int j=low; j