Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f29a337

Browse files
author
Ram swaroop
committed
quick sort: code refactoring
1 parent e448255 commit f29a337

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/me/ramswaroop/arrays/QuickSort.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ public static int partition(int[] ar, int low, int high) {
5757
* @param low
5858
* @param high
5959
*/
60-
public static void sort(int[] ar, int low, int high) {
60+
public static void quickSort(int[] ar, int low, int high) {
6161
if (low < high) {
6262
int partition = partition(ar, low, high);
63-
sort(ar, low, partition - 1);
64-
sort(ar, partition + 1, high);
63+
quickSort(ar, low, partition - 1);
64+
quickSort(ar, partition + 1, high);
6565
}
6666
}
6767

6868
public static void main(String a[]) {
6969
int[] ar = {3, 2, 1, 6, 4, 9, 7, 8};
7070
System.out.println(Arrays.toString(ar));
71-
sort(ar, 0, ar.length - 1);
71+
quickSort(ar, 0, ar.length - 1);
7272
System.out.println(Arrays.toString(ar));
7373
}
7474
}

0 commit comments

Comments
 (0)