学习笔记
ᴿᵒᵃʳ
这个作者很懒,什么都没留下…
展开
-
堆排序思想及C++实现
构造一个小顶堆,取堆顶数字(也就是最小值) 再将剩下的数字构建一个小顶堆,取堆顶数字(也就是剩下值当中的最小值) 重复以上操作,直到取完堆中的数字,最终得到一个从小到大排序的序列 ...转载 2020-09-28 21:04:50 · 89 阅读 · 0 评论 -
快速排序思想及C++实现
快速排序的思想 step 1. 通过一趟排序把数据分成两部分,其中\color{red}{其中}其中一部分的所有数据都要比另一部分的所有数据小,基准数据(枢轴)排在这两个子序列的中间 step 2. int partition(int array[], int low, int high){ int pv = array[low]; while(low < high){ while(low < high && array[high] >= pv) --hi原创 2020-09-21 19:18:29 · 143 阅读 · 0 评论