diff --git a/QSort.java b/QSort.java index 635e5dd..6f96655 100644 --- a/QSort.java +++ b/QSort.java @@ -1,29 +1,32 @@ +class SortArray +{ + public sort(int a[]) + { + int temp; + for(int i=0;i<=a.length;i++) + { + for(int j=i+1;ja[j]) + { + temp=a[i]; + a[i]=a[j]; + a[j]=temp; + } + } + } + for(int k=0;k= 1) - { int pivot = array[start]; - while (k > i) - { while (array[i] <= pivot && i <= end && k > i) i++; - while (array[k] > pivot && k >= start && k >= i) k--; - if (k > i) swap(array, i, k); - } - swap(array, start, k); - quickSort(array, start, k - 1); // quicksort the left partition - quickSort(array, k + 1, end); // quicksort the right partition - } - }//quickSort() - void swap(int array[], int index1, int index2) - { int temp = array[index1]; - array[index1] = array[index2]; - array[index2] = temp; - }//swap() -}//class \ No newline at end of file +}