数据结构_排序_快速排序

2015-09-13  本文已影响77人  arkulo

github地址:
https://github.com/arkulo56/thought/blob/master/software/dataStruct/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84_%E6%8E%92%E5%BA%8F_%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F.md

数据结构_排序_快速排序

定义

算法实现

<img src="https://raw.githubusercontent.com/arkulo56/thought/master/images/datastruct/sort_fast_1.png" width="500" />

<img src="https://raw.githubusercontent.com/arkulo56/thought/master/images/datastruct/sort_fast_2.png" width="500" />

代码中,Partition函数实现了排序和形成左右子数列,是快速排序的关键,下图展示了该函数第一次执行的过程,便于大家理解快速排序

<img src="https://raw.githubusercontent.com/arkulo56/thought/master/images/datastruct/sort_fast.png" width="400" />

上一篇 下一篇

猜你喜欢

热点阅读