堆排序
blue_sister
这个作者很懒,什么都没留下…
展开
-
堆的模板
#include<bits/stdc++.h> using namespace std; const int maxn = 100; int heap[maxn];//数组存的数据从下标为1开始 int n = 100; //low为要数组中要调节元素对应的下标,high为数组中最后一个元素所对映的下标 void downAdjust(int low,int high){ //i为父节点,j为左儿子节点 int i = low,j = low*2; while(i<原创 2021-04-17 13:47:45 · 111 阅读 · 0 评论 -
1098 Insertion or Heap Sort (25 分)
参考代码 1.堆排序 #include <iostream> #include <algorithm> #include <vector> using namespace std; void downAdjust(vector<int> &b, int low, int high) { int i = 1, j = i * 2; while(j <= high) { if(j + 1 <= high &原创 2021-04-15 00:16:09 · 66 阅读 · 0 评论