Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this assignment fill an array of 1 0 integers with random values ranging from 0 to 1 0 0 . Convert all the functions
For this assignment fill an array of integers with random values ranging from to
Convert all the functions written in the lecture video in such a way that they produce a min heap instead of a max heap.
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 heapifyint 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 andor 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 printHeapint heap int lastIndex;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started