Question: First write a method to read the input data into an array representing a heap. The input data is the Test case input. Return the

First write a method to read the input data into an array representing a heap. The input data is the Test case input. Return the size of the heap. A pointer to the heap array is a parameter of readheap.

Then write a method to remove an item from the heap.

Then write a method to print the heap. Print the data as shown in the Test case output.

Sample Input 1:

1 4 3 10 12 6 

Sample Output 1:

3 4 6 10 12 

Sample Input 2:

1 4

Sample Output 2:

4

Sample Input 3:

1 4 3 6 5

Sample Output 3:

3 4 5 6

#include #include #include using namespace std;

int readheap(int * theheap) {

//write code

}

void heapRemove(int * theheap, int size) { //write code }

void heapPrint(int * theheap, int size) { //write code }

int main() { int * theheap = new int[10]; int size = readheap(theheap); heapRemove(theheap, size); heapPrint(theheap, size); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!