Question: fill an array of 1 0 integers with random values ranging from 0 to 1 0 0 . convert all these functions in a way

fill an array of 10 integers with random values ranging from 0 to 100. convert all these functions in a way that they produce a mn heap instead of a max heap. void insertHeap(int heap[], int key, int &lastIndex);
void reheapUp(int heap[], int locIndex);
void deleteHeap(int heap[], int &lastIndex);
void reheapDown(int heap[], int locIndex, int lastIndex);
void heapify(int heap[], int &lastIndex, int size);
void printHeap(int heap[], int lastIndex);
Write a function called heapify that takes an array of any length of random integers, and converts it into a valid min heap. The function signature should look like: void heapify(int heap[], int &lastIndex, int size); The parameters heap and lastIndex are used in the same way as the other functions use them. The variable size has the number of elements inside of the array to begin with. Your function should also set lastIndex to its appropriate value. Notice that lastIndex is being passed by reference. This function may use reheapUp and/or reheapDown as needed.
Write a function that takes in a min heap and prints all the contents in ascending order without using any other sorting algorithm or function. When the function ends, the heap array passed into the function should still be a valid min heap (the values may be in a somewhat different order, that's fine). You can use a temporary array to store values if you like. The function signature should be: void printHeap(int heap[], int lastIndex);

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!