|
|
|
@ -98,10 +98,39 @@ public class SortUtil { |
|
|
|
|
* @param arr |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static int[] quickSort(int[] arr){ |
|
|
|
|
public static void quickSort(int[] arr){ |
|
|
|
|
int low = 0; |
|
|
|
|
int high = arr.length-1; |
|
|
|
|
return arr; |
|
|
|
|
if (high-low<1){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
boolean flag = true; |
|
|
|
|
int start = low; |
|
|
|
|
int end = high; |
|
|
|
|
int midValue = arr[low]; |
|
|
|
|
while (true){ |
|
|
|
|
if (flag){ |
|
|
|
|
if (arr[high]>midValue){ |
|
|
|
|
high--; |
|
|
|
|
}else if (arr[high]<midValue){ |
|
|
|
|
arr[low] = arr[high]; |
|
|
|
|
low++; |
|
|
|
|
flag = false; |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
if (arr[low]<midValue){ |
|
|
|
|
low++; |
|
|
|
|
}else if (arr[low]>midValue){ |
|
|
|
|
arr[high] = arr[low]; |
|
|
|
|
high--; |
|
|
|
|
flag = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (low == high){ |
|
|
|
|
arr[low] = midValue; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|