Altered
This commit is contained in:
78
BinaryTree/priorityQueue/maxHeap/main.cpp
Normal file
78
BinaryTree/priorityQueue/maxHeap/main.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
#include "maxHeap.h"
|
||||
using namespace std;
|
||||
int main() {
|
||||
maxHeap<int> h;
|
||||
h.push(9);
|
||||
h.push(8);
|
||||
h.push(7);
|
||||
h.push(6);
|
||||
h.push(5);
|
||||
h.push(4);
|
||||
h.push(3);
|
||||
h.push(2);
|
||||
h.push(1);
|
||||
h.display();
|
||||
/*
|
||||
* 9
|
||||
* 8 7
|
||||
* 6 5 4 3
|
||||
* 2 1
|
||||
*/
|
||||
h.push(10);
|
||||
h.display();
|
||||
h.push(11);
|
||||
h.display();
|
||||
h.push(12);
|
||||
h.display();
|
||||
/*
|
||||
* 12
|
||||
* 10 11
|
||||
* 6 9 7 3
|
||||
* 2 1 5 8 4
|
||||
*/
|
||||
h.pop();
|
||||
h.display();
|
||||
h.pop();
|
||||
h.display();
|
||||
h.pop();
|
||||
h.display();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
输出结果与预测的一致
|
||||
9
|
||||
8 7
|
||||
6 5 4 3
|
||||
2 1
|
||||
|
||||
10
|
||||
9 7
|
||||
6 8 4 3
|
||||
2 1 5
|
||||
|
||||
11
|
||||
10 7
|
||||
6 9 4 3
|
||||
2 1 5 8
|
||||
|
||||
12
|
||||
10 11
|
||||
6 9 7 3
|
||||
2 1 5 8 4
|
||||
|
||||
11
|
||||
10 7
|
||||
6 9 4 3
|
||||
2 1 5 8
|
||||
|
||||
10
|
||||
9 7
|
||||
6 8 4 3
|
||||
2 1 5
|
||||
|
||||
9
|
||||
8 7
|
||||
6 5 4 3
|
||||
2 1
|
||||
*/
|
Reference in New Issue
Block a user