public class test1 { public static void main(String[] args) { quickSort(a,0,5); } /** * 快速排序*/ public static void quickSort(int[] arrays,int start,int end){ if(start>=end){ return; } int index=partition(arrays,start,end); quickSort(arrays,start,index-1); quickSort(arrays,index+1,end); } public static int partition(int[] arrays,int start,int end){ int key=arrays[start]; while (start<end){ while (arrays[end]>=key && start<end){ end--; } arrays[start]=arrays[end]; arrays[end]=key; while (arrays[start]<=key && start<end){ start++; } arrays[end]=arrays[start]; arrays[start]=key; } return end; }
快速排序
最新推荐文章于 2024-07-17 10:35:12 发布