CS301P Lab 11 Solution Max Heap
CS301P Lab 11 Solution Max Heap
#include<iostream>
#include<conio.h>
using namespace std;
class Heap
{
private:
int *array, current;
public:
Heap(int size)
{
array = new int[size++];
current = 0;
}
void traverse()
{
for(int i=1; i<=current; i++)
{
cout << array[i] << " ";
}
}
};
main()
{
int size = 16;
int array[size] = {18, 31, 82, 85, 37, 20, 23, 79, 47, 51, 96, 97, 42, 94,
57, 29};
Heap obj(size);
for(int i=0; i<size; i++)
{
obj.insert(array[i]);
}
cout << "*** Max Heap Using Insert Method ***\n\n";
obj.traverse();
getch();
return 0;
}