其他分享
首页 > 其他分享> > 5.快排(不稳定)

5.快排(不稳定)

作者:互联网

public static  int Partition(int[] nums,int left,int right){

        int prvot=nums[left];
        while (left<right)
        {
            while (left<right&&nums[right]>=nums[left])right--;
            nums[left]=nums[right];
            while (left<right&&nums[left]<=nums[right])left++;
            nums[right]=nums[left];


        }
        nums[left]=prvot;
        return left;
    }
    public static void   QuickSort(int[] nums,int left,int right){
        if(left<right)
        {
            int partition = Partition(nums, left, right);
            QuickSort(nums,left,partition-1);
            QuickSort(nums,partition+1,right);

        }





    }

 

标签:稳定,right,nums,int,Partition,快排,while,left
来源: https://www.cnblogs.com/upupup-999/p/16220872.html