quicksork
步骤:
- shuffle (needed for performance guarantee)
partition (scan i and j, repeat until i and j pointers cross. at last, exchange a[lo] with a[j]. )
– entry a[j] is in place
– no larger entry to the left of j
– no smaller entry to the right of jsort recursively
例子:
Q U I C K S O R T E X A M P L E
shuffle:K R A T E L E P U I M Q C X O S
partition: E C A I E K L P U T M Q R X O S
sort left
sort right
参考文献:
Algorithms, 4th Edition