quicksork解析

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 j

  • sort 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

posted @ 2018-01-07 20:25  钢珠子  阅读(214)  评论(0编辑  收藏  举报