zoukankan      html  css  js  c++  java
  • Quick sort C# code

    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);
            }
           
    }

  • 相关阅读:
    Lyndon Word & The Runs Theorem
    Codeforces 1477F. Nezzar and Chocolate Bars
    Codeforces Round #700 (Div.1)
    kubeadm 安装 k8s
    centos7更新阿里yum源
    CF1186 F. Vus the Cossack and a Graph
    CF1152 D. Neko and Aki's Prank
    CF803 C. Maximal GCD
    CF1180 B. Nick and Array
    CF1186 D. Vus the Cossack and Numbers
  • 原文地址:https://www.cnblogs.com/stone/p/1232343.html
Copyright © 2011-2022 走看看