Question: Please help me implement some functions about heap using BST, C++, Thanks! And here's the test need to pass. // examheap.cpp #include heap.h #include #include
Please help me implement some functions about heap using BST, C++, Thanks!


And here's the test need to pass.
// examheap.cpp
#include "heap.h"
#include
#include
#include
#include
#include
#include
using namespace std;
int main(int argc, char *argv[]) {
if (argc
cout
return 1;
}
int t = atoi(argv[1]);
std::priority_queue
Heap h;
int numvals = 3;
if (t == 1) {
cout
int sum = 0, count = 0;
Heap h;
srand(time(0));
int arand = rand() % 1000;
int brand = arand -10;
h.push(arand);
assert(h.top()==arand);
h.pop();
assert(h.empty());
h.push(arand);
h.push(brand);
assert(h.top()==brand);
h.pop();
h.pop();
assert(h.empty());
h.push(brand);
h.push(arand);
assert(!h.empty());
assert(h.top()==brand);
cout
return 0;
}
if (t == 2) {
cout
numvals = 3;
}
if (t == 3) {
cout
numvals = 4;
}
if (t == 4){
cout
numvals = 200;
}
if (t == 5){
cout
numvals = 20000;
}
for (int i=0; i
int arand = rand() % 2000;
data.push(arand);
h.push(arand);
}
while(!data.empty()){
assert(!h.empty());
assert(data.top()==h.top());
data.pop();
h.pop();
}
cout
return 0;
}
o heap.cpp- Edited heap.cpp No Selection 1 // heap.cpp 4 #include "heap.h" #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
