public class IntQuickSort
{
        private static int Split(int[] data,int low,int high)
       {
             if(data == null) throw new ArgumentException();
             if(low<0 || high >= data.length) throw new ArgumentOutOfRangeException();

             int pivot= data[low];
             while(low<high)
             {
                    while(low<high && data[high] >= pivot) high--;
                    data[low] = data[high];
                    while(low<high && data[low] <= pivot) low++;
                    data[high] = data[low];
              }
              data[low] = pivot;
              return low;
        }

        //recursion quick sort
        public static void QuickSort(int[] data,int low,int high)
       {
            int pivot= Split(data,low,high);
            QuickSort(data,low,pivot-1);
            QuickSort(data,pivot+1,high);
        }
       
}

相关文章:

  • 2021-11-01
  • 2021-10-06
  • 2021-09-24
  • 2021-10-16
  • 2022-02-18
猜你喜欢
  • 2022-12-23
  • 2021-03-30
  • 2022-02-09
  • 2021-08-23
相关资源
相似解决方案