Question: I need the completed code in C++ WITHOUT using the algorithm library. All functions must follow the format listed in the pictures given. There is


I need the completed code in C++ WITHOUT using the algorithm library. All functions must follow the format listed in the pictures given.
There is a well-studied data structure called a binary heap. It is very efficient in maintaining and pro- viding a list of minimum or maximum values from a set. It is nearly always used in implementing a priority queue -a scheduling tool. Your understanding of this structurel be expected in CSCE 311. They are used in tnanaging processes in CPU I would like to be able to treat an integer array as a max heap A max heap uses a binary tree stored in a special way. Rather than nodes and pointers, the entire structure is kept in an array. The left and right children of each node at index n are stored at indices 2n +1 anod 2n +2, respectively. I would highly recommend making making two functions, inline int left(int root); and inline int right(int root); Each function simply returns the calculation, where root is n. Less mess, easier to read, and little chance of calculation errors. One more function which be highly valuable is line int parent (int child); This function inspects the child's index, determines if it is a right or left child and uses that information to calculate the parent index of the given child index. You must provide the following functions: . void Add (int item, int heap, int count) Function accepts an item to be added to heap, an array representing the heap, and count, the current number of items in the heap. - Precondition(s) Size of int array heap is greater than count s item is stored in heap s Heap Property: For each node in the tree stored in heap, a node's children's values are less than the node's value. - Algorithm: 1. Add the element to the bottom level of the heap. 2. Compare the added element with its parent if they are in the correct order, stop. 3. If not, swap the element with its parent and return to the previous step
Step by Step Solution
There are 3 Steps involved in it
To implement the binary max heap as described well follow the guidelines of creating a few helper fu... View full answer
Get step-by-step solutions from verified subject matter experts
