public void quickSort(int[] arr,int low,int high){
if(low<high){
int index = getIndex(arr,low,high);
quickSort(arr,low,index-1);
quickSort(arr,index+1,high);
}
}
public int getIndex(int arr[],int low,int high){
int n = arr[low];
while(low<high){
while(low<high && arr[high]>=n){
high--;
}
arr[low] = arr[high];
while(low<high && arr[low]<=n){
low++;
}
arr[high] = arr[low];
}
arr[low] = n;
return low;
}
快速排序(java)
最新推荐文章于 2024-03-19 09:27:29 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)