ݺߣ

ݺߣShare a Scribd company logo
Arrays  sort 㷨

                      Zianed Hou
                    zianed@live.cn




1Arrays.sort

2int[]ʵ

3ʵ˿ɱȽϽӿComparable бȽ

4ûпɱȽԣбȽʱҪȽ

5㷨qsortͺϲ㷨ʵ




Zianed                 Version 1.0   1
1Arrays.sort
Arrays ṩ˶Ի bytechardoublefloatintlong 
ʵ֡
Arrays ṩ˶ԶıȽϡ
ʵֿɱȽϽӿڵģֱӽбȽϣ
public static void sort(Object[] a)бȽ
ûʵֱȽϽӿڵģһȽȽԽжԸֶ͵ıȽϣ
public static <T> void sort(T[] a,Comparator<? super T> c)

ϵ㷨ṩ,formIndex  toIndex С




2int[]ʵ
ͬ int[]
鿴 API Է sort ṩַʵ֣
//Χ
public static void sort(int[] a) {
     sort1(a, 0, a.length);
}
//Χ
public static void sort(int[] a, int fromIndex, int toIndex) {
    rangeCheck(a.length, fromIndex, toIndex);//˷Χ
    sort1(a, fromIndex, toIndex-fromIndex);
}


ͨԿǵº
private static void sort1(int x[], int off, int len)



صú˵
1)У飬֤εЧԣ
##ĺôǣǵļǶջڴʱЧ
##ԣԱѹջĹеʱ䡢ռġӦһֱƼ
##
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex)
{


Zianed                          Version 1.0                            2
if (fromIndex > toIndex)
            throw new IllegalArgumentException("fromIndex(" + fromIndex +
                        ") > toIndex(" + toIndex+")");
         if (fromIndex < 0)
            throw new ArrayIndexOutOfBoundsException(fromIndex);
         if (toIndex > arrayLen)
            throw new ArrayIndexOutOfBoundsException(toIndex);
}


2)Ԫ,ͨм
##ռݽһձʹõķȻʹʱ任ռķһ
##ֻڿռԴȱʹáһΪʱȱռλ
private static void swap(int x[], int a, int b)
{
         int t = x[a];
         x[a] = x[b];
         x[b] = t;
}


3)еһԪ
##± a ʼ n Ԫ± b ʼ n Ԫ,ν swap
##ʵʵݽ
private static void vecswap(int x[], int a, int b, int n)
{
         for (int i = 0; i < n; i++, a++, b++)
            swap(x, a, b);
}


4)±ԪеռмԪصλá
##ĿݵıȽ
##ֵռмԪصλ
private static int med3(int x[], int a, int b, int c)
{
         return (x[a] < x[b] ? (x[b] < x[c] ? b : x[a] < x[c] ? c : a)
               : (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
}


ĺ
˵
X[]:Ҫ
Int off:Ԫصʼλ
Int len:ҪԪصĸ
private static void sort1(int x[], int off, int len)
{


Zianed                              Version 1.0                          3
// Insertion sort on smallest arrays
         ##
         if (len < 7)
         {
             for (int i = off; i < len + off; i++)
                 for (int j = i; j > off && x[j - 1] > x[j]; j--)
                    swap(x, j, j - 1);
             return;
         }


         // Choose a partition element, v
          ##ѡָԪv


         ##ҵλмԪ
         int m = off + (len >> 1); // Small arrays, middle element


         ##ҪԪظ7ʱ
          ##elseֻе7
          if (len > 7)
         {
             int l = off;
             int n = off + len - 1;
             if (len > 40)
             {
                 // Big arrays, pseudomedian of 9
                 int s = len / 8;
                 l = med3(x, l, l + s, l + 2 * s);
                 m = med3(x, m - s, m, m + s);
                 n = med3(x, n - 2 * s, n - s, n);
             }
              ##ȡüмֵ
             m = med3(x, l, m, n); // Mid-size, med of 3
         }
         int v = x[m];


         // Establish Invariant: v* (<v)* (>v)* v*
         int a = off, b = a, c = off + len - 1, d = c;
          ##aΪʼԪλ,baͬ,dΪԪλ;cͬd
          ##a,dǹ̶,Ϊ綨Ԫ;b,cԱ


         while (true)
         {
             while (b <= c && x[b] <= v)
             {


Zianed                              Version 1.0                      4
if (x[b] == v)
                    swap(x, a++, b);
                 b++;
             }
             while (c >= b && x[c] >= v)
             {
                 if (x[c] == v)
                    swap(x, c, d--);
                 c--;
             }
             if (b > c)
                 break;
             swap(x, b++, c--);
         }


         // Swap partition elements back to middle
         int s, n = off + len;
         ##
         s = Math.min(a - off, b - a);
         vecswap(x, off, b - s, s);
         ##
         s = Math.min(d - c, n - d - 1);
         vecswap(x, b, n - s, s);


         // Recursively sort non-partition-elements
         ##a-b֮Ԫ
         if ((s = b - a) > 1)
             sort1(x, off, s);
         ##cd֮Ԫ
         if ((s = d - c) > 1)
             sort1(x, n - s, s);
}


ĵıʹõDzõĶԿһָĽֶνв
ҵһģмֵ(ֵϵ)мֵֶν
ֳɵСʹõǿ




Zianed                              Version 1.0       5
3ʵ˿ɱȽϽӿComparable 
бȽ
INSERTIONSORT_THRESHOLD ʾʼ,Сڴٽֵʱ
                                             в
õ 2·鲢
ǰһͺһֱʹȻкϲ
㷨ȶģO nlog2(n)Ч


/**
 * used in preference to mergesort or quicksort.
 */
private static final int INSERTIONSORT_THRESHOLD = 7;


private static void mergeSort(Object[] src, Object[] dest,
                    int low, int high, int off) {
      int length = high - low;
      // Insertion sort on smallest arrays
      if (length < INSERTIONSORT_THRESHOLD) {
          for (int i=low; i<high; i++)
           for (int j=i; j>low &&
           ((Comparable) dest[j-1]).compareTo(dest[j])>0; j--)
                  swap(dest, j, j-1);
                  return;
      }
           // Recursively sort halves of dest into src
           int destLow = low;
           int destHigh = high;
           low += off;
           high += off;
           int mid = (low + high) >>> 1;
           ##ݹǰһͺһй鲢
           mergeSort(dest, src, low, mid, -off);
           mergeSort(dest, src, mid, high, -off);


// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
#ǰһͺһֱ򣬲ǰһֵСڵںһСֵôֱӽкϲ
if (((Comparable)src[mid-1]).compareTo(src[mid]) <= 0) {
              System.arraycopy(src, low, dest, destLow, length);
              return;
}


Zianed                              Version 1.0                      6
// Merge sorted halves (now in src) into dest
    #ԸöνбȽϵĺϲ
    #p ʾǰһε±
    #q ʾһε±
    for(int i = destLow, p = low, q = mid; i < destHigh; i++) {
    #1q>=highʾһѾȫˣǰһʣݸƵĿ
    #2p<mid ʾǰһݻʣ࣬ҪԸһݽбȽ
    # src[p]<= src[q] ˵ǰһеpСڵqôǰһеpĿ
     if (q >= high || p < mid && ((Comparable)src[p]).compareTo(src[q])<=0)
                    dest[i] = src[p++];
    #1p>=midǰһѾȫˣһʣݸƵĿ
    #2p<mid ʾǰһݻʣ࣬ҪԸһݽбȽ
    # src[p]> src[q] ˵ǰһеpqôƺһеqĿ
     else
                    dest[i] = src[q++];
    }
}


/**
    * Swaps x[a] with x[b].
    */
private static void swap(Object[] x, int a, int b) {
        Object t = x[a];
        x[a] = x[b];
        x[b] = t;
}




4ûпɱȽԣбȽʱҪ
Ƚ
INSERTIONSORT_THRESHOLD ʾʼ,Сڴٽֵʱ
                                             в
õ 2·鲢
ǰһͺһֱʹȻкϲ
㷨ȶģO nlog2(n)Ч.


㷨ǰͬڱȽϵʱDzõıȽ


private static void mergeSort(Object[] src,
                       Object[] dest,
                       int low, int high, int off,


Zianed                                  Version 1.0                       7
Comparator c) {
     int length = high - low;


     // Insertion sort on smallest arrays
     if (length < INSERTIONSORT_THRESHOLD) {
         for (int i=low; i<high; i++)
         for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--)
              swap(dest, j, j-1);
         return;
     }


         // Recursively sort halves of dest into src
         int destLow = low;
         int destHigh = high;
         low += off;
         high += off;
         int mid = (low + high) >>> 1;
         mergeSort(dest, src, low, mid, -off, c);
         mergeSort(dest, src, mid, high, -off, c);


   // If list is already sorted, just copy from src to dest. This is an
  // optimization that results in faster sorts for nearly ordered lists.
         if (c.compare(src[mid-1], src[mid]) <= 0) {
             System.arraycopy(src, low, dest, destLow, length);
             return;
         }


         // Merge sorted halves (now in src) into dest
         for(int i = destLow, p = low, q = mid; i < destHigh; i++) {
             if (q >= high || p < mid && c.compare(src[p], src[q]) <= 0)
                 dest[i] = src[p++];
             else
                 dest[i] = src[q++];
         }
    }




5㷨qsortͺϲ㷨
ʵ
Dzȶġ


Zianed                                Version 1.0                       8
ϲȶġ


һõ㷨һЩʹõĹгҪȽд˲
public static int binarySearch() ֲǻ


͵㷨
һŵĿ򷨣ı Jon L. Bentley  M. Douglas McIlroy 
Engineering a Sort Function", Software-Practice and Experience Vol. 23(11) P. 1249-1265
(November 1993)㷨ݼṩ n*log(n) ܣ⵼ή
ܡ
㷨ԭ
http://www.enseignement.polytechnique.fr/profs/informatique/Luc.Maran
get/421/09/bentley93engineering.pdf

ƪģԿ㷨ĸĽ򣬽һλȡĽ㷨
һ˼·




References
http://www.docin.com/p-26519551.html
http://hi./helloyanwo/blog/item/bd39af6ce372a1f142169409.html
http://www.cuyoo.com/html/shenghuo/2009/0304/1015.html
http://nknucc.nknu.edu.tw/~jwu/datastr/datastr.htm
http://www.enseignement.polytechnique.fr/profs/informatique/Luc.Maranget/421/09
/bentley93engineering.pdf
http://cs.umaine.edu/~chaw/200801/capstone/n/enggsort.pdf




Zianed                                 Version 1.0                                    9
Zianed
Homepagehttp://my.unix-center.net/~Zianed/
Mail hxuanzhe86@sina.com
MSNzianed@live.cn
QQ1196123432
QQGroup 50457022
Date2009-10-24




Zianed                         Version 1.0    10

More Related Content

What's hot (20)

ʲٳDzţ5߱ر
ʲٳDzţ5߱رʲٳDzţ5߱ر
ʲٳDzţ5߱ر
Derek Lee
?
ʽ-ʽ޼
ʽ-ʽ޼ʽ-ʽ޼
ʽ-ʽ޼
卿Ƽ
?
ʽ-ָ
ʽ-ָʽ-ָ
ʽ-ָ
卿Ƽ
?
Python ޒȦI
Python ޒȦIPython ޒȦI
Python ޒȦI
a (ShyiShiou Wu)
?
ʲٳDzԴӦ
ʲٳDzԴӦʲٳDzԴӦ
ʲٳDzԴӦ
a (ShyiShiou Wu)
?
JavaScript } 2017Q1
JavaScript } 2017Q1JavaScript } 2017Q1
JavaScript } 2017Q1
Sheng-Han Su
?
Python learn guide
Python learn guidePython learn guide
Python learn guide
robin yang
?
nodeMCU IOŤW02 - LuaZ
nodeMCU IOŤW02 - LuaZnodeMCU IOŤW02 - LuaZ
nodeMCU IOŤW02 - LuaZ
a (ShyiShiou Wu)
?
C++11 smart pointers
C++11 smart pointersC++11 smart pointers
C++11 smart pointers
chchwy Chang
?
COSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in JuliaCOSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in Julia
A
?
ʲٳDzԻ
ʲٳDzԻʲٳDzԻ
ʲٳDzԻ
a (ShyiShiou Wu)
?
Cypher ѯ
Cypher ѯCypher ѯ
Cypher ѯ
zernel
?
Java CollectionsеFail Fast
Java CollectionsеFail FastJava CollectionsеFail Fast
Java CollectionsеFail Fast
yiditushe
?
Ch10 ̌W
Ch10 ̌WCh10 ̌W
Ch10 ̌W
hungchiayang1
?
ʲٳDzԷ֧ҵ
ʲٳDzԷ֧ҵʲٳDzԷ֧ҵ
ʲٳDzԷ֧ҵ
a (ShyiShiou Wu)
?
PythonʽOӋ - Yϑ
PythonʽOӋ - Yϑ PythonʽOӋ - Yϑ
PythonʽOӋ - Yϑ
a (ShyiShiou Wu)
?
PythonʽOӋ - ֧I
PythonʽOӋ - ֧IPythonʽOӋ - ֧I
PythonʽOӋ - ֧I
a (ShyiShiou Wu)
?
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryA Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
Wen Liao
?
PythonʽOӋ - ޒȦI
PythonʽOӋ - ޒȦIPythonʽOӋ - ޒȦI
PythonʽOӋ - ޒȦI
a (ShyiShiou Wu)
?

Viewers also liked (7)

û
ûû
û
Zianed Hou
?
İDzԲٰԳԼ1.1
İDzԲٰԳԼ1.1İDzԲٰԳԼ1.1
İDzԲٰԳԼ1.1
Zianed Hou
?
OracleExam Adminv1.1
OracleExam Adminv1.1OracleExam Adminv1.1
OracleExam Adminv1.1
Zianed Hou
?
еĹDz&;ٴdzܲԼ754о1.0
еĹDz&;ٴdzܲԼ754о1.0еĹDz&;ٴdzܲԼ754о1.0
еĹDz&;ٴdzܲԼ754о1.0
Zianed Hou
?
г
гг
г
Zianed Hou
?
Сʹڴ
СʹڴСʹڴ
Сʹڴ
Zianed Hou
?
ݿ־´
ݿ־´ݿ־´
ݿ־´
Zianed Hou
?
Ad

Similar to ijǰ㷨 (15)

DB_Algorithm_and_Data_Structure_About_Sort
DB_Algorithm_and_Data_Structure_About_Sort DB_Algorithm_and_Data_Structure_About_Sort
DB_Algorithm_and_Data_Structure_About_Sort
Lixun Peng
?
10
1010
10
Wesley Chen
?
ڶ Ա
ڶ Աڶ Ա
ڶ Ա
Wang Yizhe
?
10 ۺӦ(java)
10  ۺӦ(java)10  ۺӦ(java)
10 ۺӦ(java)
Yan Li
?
ջͶ
 ջͶ ջͶ
ջͶ
Wang Yizhe
?
ھ [2]
ھ [2]ھ [2]
ھ [2]
Wang Yizhe
?
ջͶ()
 ջͶ() ջͶ()
ջͶ()
Wang Yizhe
?
ݽṹϰʼ ̬
ݽṹϰʼ ̬ݽṹϰʼ ̬
ݽṹϰʼ ̬
mengyingchina
?
08 (java)
08  (java)08  (java)
08 (java)
Yan Li
?
Chapter 5 array and struct
Chapter 5 array and structChapter 5 array and struct
Chapter 5 array and struct
hhliu
?
ϲ
ϲϲ
ϲ
ϲ ϲ
?
Ad

ijǰ㷨

  • 1. Arrays sort 㷨 Zianed Hou zianed@live.cn 1Arrays.sort 2int[]ʵ 3ʵ˿ɱȽϽӿComparable бȽ 4ûпɱȽԣбȽʱҪȽ 5㷨qsortͺϲ㷨ʵ Zianed Version 1.0 1
  • 2. 1Arrays.sort Arrays ṩ˶Ի bytechardoublefloatintlong ʵ֡ Arrays ṩ˶ԶıȽϡ ʵֿɱȽϽӿڵģֱӽбȽϣ public static void sort(Object[] a)бȽ ûʵֱȽϽӿڵģһȽȽԽжԸֶ͵ıȽϣ public static <T> void sort(T[] a,Comparator<? super T> c) ϵ㷨ṩ,formIndex toIndex С 2int[]ʵ ͬ int[] 鿴 API Է sort ṩַʵ֣ //Χ public static void sort(int[] a) { sort1(a, 0, a.length); } //Χ public static void sort(int[] a, int fromIndex, int toIndex) { rangeCheck(a.length, fromIndex, toIndex);//˷Χ sort1(a, fromIndex, toIndex-fromIndex); } ͨԿǵº private static void sort1(int x[], int off, int len) صú˵ 1)У飬֤εЧԣ ##ĺôǣǵļǶջڴʱЧ ##ԣԱѹջĹеʱ䡢ռġӦһֱƼ ## private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) { Zianed Version 1.0 2
  • 3. if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex+")"); if (fromIndex < 0) throw new ArrayIndexOutOfBoundsException(fromIndex); if (toIndex > arrayLen) throw new ArrayIndexOutOfBoundsException(toIndex); } 2)Ԫ,ͨм ##ռݽһձʹõķȻʹʱ任ռķһ ##ֻڿռԴȱʹáһΪʱȱռλ private static void swap(int x[], int a, int b) { int t = x[a]; x[a] = x[b]; x[b] = t; } 3)еһԪ ##± a ʼ n Ԫ± b ʼ n Ԫ,ν swap ##ʵʵݽ private static void vecswap(int x[], int a, int b, int n) { for (int i = 0; i < n; i++, a++, b++) swap(x, a, b); } 4)±ԪеռмԪصλá ##ĿݵıȽ ##ֵռмԪصλ private static int med3(int x[], int a, int b, int c) { return (x[a] < x[b] ? (x[b] < x[c] ? b : x[a] < x[c] ? c : a) : (x[b] > x[c] ? b : x[a] > x[c] ? c : a)); } ĺ ˵ X[]:Ҫ Int off:Ԫصʼλ Int len:ҪԪصĸ private static void sort1(int x[], int off, int len) { Zianed Version 1.0 3
  • 4. // Insertion sort on smallest arrays ## if (len < 7) { for (int i = off; i < len + off; i++) for (int j = i; j > off && x[j - 1] > x[j]; j--) swap(x, j, j - 1); return; } // Choose a partition element, v ##ѡָԪv ##ҵλмԪ int m = off + (len >> 1); // Small arrays, middle element ##ҪԪظ7ʱ ##elseֻе7 if (len > 7) { int l = off; int n = off + len - 1; if (len > 40) { // Big arrays, pseudomedian of 9 int s = len / 8; l = med3(x, l, l + s, l + 2 * s); m = med3(x, m - s, m, m + s); n = med3(x, n - 2 * s, n - s, n); } ##ȡüмֵ m = med3(x, l, m, n); // Mid-size, med of 3 } int v = x[m]; // Establish Invariant: v* (<v)* (>v)* v* int a = off, b = a, c = off + len - 1, d = c; ##aΪʼԪλ,baͬ,dΪԪλ;cͬd ##a,dǹ̶,Ϊ綨Ԫ;b,cԱ while (true) { while (b <= c && x[b] <= v) { Zianed Version 1.0 4
  • 5. if (x[b] == v) swap(x, a++, b); b++; } while (c >= b && x[c] >= v) { if (x[c] == v) swap(x, c, d--); c--; } if (b > c) break; swap(x, b++, c--); } // Swap partition elements back to middle int s, n = off + len; ## s = Math.min(a - off, b - a); vecswap(x, off, b - s, s); ## s = Math.min(d - c, n - d - 1); vecswap(x, b, n - s, s); // Recursively sort non-partition-elements ##a-b֮Ԫ if ((s = b - a) > 1) sort1(x, off, s); ##cd֮Ԫ if ((s = d - c) > 1) sort1(x, n - s, s); } ĵıʹõDzõĶԿһָĽֶνв ҵһģмֵ(ֵϵ)мֵֶν ֳɵСʹõǿ Zianed Version 1.0 5
  • 6. 3ʵ˿ɱȽϽӿComparable бȽ INSERTIONSORT_THRESHOLD ʾʼ,Сڴٽֵʱ в õ 2·鲢 ǰһͺһֱʹȻкϲ 㷨ȶģO nlog2(n)Ч /** * used in preference to mergesort or quicksort. */ private static final int INSERTIONSORT_THRESHOLD = 7; private static void mergeSort(Object[] src, Object[] dest, int low, int high, int off) { int length = high - low; // Insertion sort on smallest arrays if (length < INSERTIONSORT_THRESHOLD) { for (int i=low; i<high; i++) for (int j=i; j>low && ((Comparable) dest[j-1]).compareTo(dest[j])>0; j--) swap(dest, j, j-1); return; } // Recursively sort halves of dest into src int destLow = low; int destHigh = high; low += off; high += off; int mid = (low + high) >>> 1; ##ݹǰһͺһй鲢 mergeSort(dest, src, low, mid, -off); mergeSort(dest, src, mid, high, -off); // If list is already sorted, just copy from src to dest. This is an // optimization that results in faster sorts for nearly ordered lists. #ǰһͺһֱ򣬲ǰһֵСڵںһСֵôֱӽкϲ if (((Comparable)src[mid-1]).compareTo(src[mid]) <= 0) { System.arraycopy(src, low, dest, destLow, length); return; } Zianed Version 1.0 6
  • 7. // Merge sorted halves (now in src) into dest #ԸöνбȽϵĺϲ #p ʾǰһε± #q ʾһε± for(int i = destLow, p = low, q = mid; i < destHigh; i++) { #1q>=highʾһѾȫˣǰһʣݸƵĿ #2p<mid ʾǰһݻʣ࣬ҪԸһݽбȽ # src[p]<= src[q] ˵ǰһеpСڵqôǰһеpĿ if (q >= high || p < mid && ((Comparable)src[p]).compareTo(src[q])<=0) dest[i] = src[p++]; #1p>=midǰһѾȫˣһʣݸƵĿ #2p<mid ʾǰһݻʣ࣬ҪԸһݽбȽ # src[p]> src[q] ˵ǰһеpqôƺһеqĿ else dest[i] = src[q++]; } } /** * Swaps x[a] with x[b]. */ private static void swap(Object[] x, int a, int b) { Object t = x[a]; x[a] = x[b]; x[b] = t; } 4ûпɱȽԣбȽʱҪ Ƚ INSERTIONSORT_THRESHOLD ʾʼ,Сڴٽֵʱ в õ 2·鲢 ǰһͺһֱʹȻкϲ 㷨ȶģO nlog2(n)Ч. 㷨ǰͬڱȽϵʱDzõıȽ private static void mergeSort(Object[] src, Object[] dest, int low, int high, int off, Zianed Version 1.0 7
  • 8. Comparator c) { int length = high - low; // Insertion sort on smallest arrays if (length < INSERTIONSORT_THRESHOLD) { for (int i=low; i<high; i++) for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--) swap(dest, j, j-1); return; } // Recursively sort halves of dest into src int destLow = low; int destHigh = high; low += off; high += off; int mid = (low + high) >>> 1; mergeSort(dest, src, low, mid, -off, c); mergeSort(dest, src, mid, high, -off, c); // If list is already sorted, just copy from src to dest. This is an // optimization that results in faster sorts for nearly ordered lists. if (c.compare(src[mid-1], src[mid]) <= 0) { System.arraycopy(src, low, dest, destLow, length); return; } // Merge sorted halves (now in src) into dest for(int i = destLow, p = low, q = mid; i < destHigh; i++) { if (q >= high || p < mid && c.compare(src[p], src[q]) <= 0) dest[i] = src[p++]; else dest[i] = src[q++]; } } 5㷨qsortͺϲ㷨 ʵ Dzȶġ Zianed Version 1.0 8
  • 9. ϲȶġ һõ㷨һЩʹõĹгҪȽд˲ public static int binarySearch() ֲǻ ͵㷨 һŵĿ򷨣ı Jon L. Bentley M. Douglas McIlroy Engineering a Sort Function", Software-Practice and Experience Vol. 23(11) P. 1249-1265 (November 1993)㷨ݼṩ n*log(n) ܣ⵼ή ܡ 㷨ԭ http://www.enseignement.polytechnique.fr/profs/informatique/Luc.Maran get/421/09/bentley93engineering.pdf ƪģԿ㷨ĸĽ򣬽һλȡĽ㷨 һ˼· References http://www.docin.com/p-26519551.html http://hi./helloyanwo/blog/item/bd39af6ce372a1f142169409.html http://www.cuyoo.com/html/shenghuo/2009/0304/1015.html http://nknucc.nknu.edu.tw/~jwu/datastr/datastr.htm http://www.enseignement.polytechnique.fr/profs/informatique/Luc.Maranget/421/09 /bentley93engineering.pdf http://cs.umaine.edu/~chaw/200801/capstone/n/enggsort.pdf Zianed Version 1.0 9