首页 » python » 正文

堆排序通过sink实现,动画演示,看不懂你砍我!

除了之前文章介绍的方法外,我们也可以通过sink的方式来排序,但是第一步都是相同的,保证堆有序

堆排序sink.001 堆排序sink.002 堆排序sink.003 堆排序sink.004 堆排序sink.005 堆排序sink.006 堆排序sink.007 堆排序sink.008 堆排序sink.009 堆排序sink.010 堆排序sink.011 堆排序sink.012 堆排序sink.013 堆排序sink.014 堆排序sink.015 堆排序sink.016 堆排序sink.017 堆排序sink.018 堆排序sink.019 堆排序sink.020 堆排序sink.021 堆排序sink.022 堆排序sink.023 堆排序sink.024 堆排序sink.025 堆排序sink.026 堆排序sink.027 堆排序sink.028 堆排序sink.029

 

就是每次首位交换以后,把根目录上的元素下沉到应该在的位置,逻辑上比上一个方法要复杂一些:

 

发表评论