Answered step by step
Verified Expert Solution
Link Copied!

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 10 integers with random values ranging from 0 to 100.
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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions