Question: 5. (20 points) This problem considers your MinHeap implementation. Suppose it has been instantiated with sufficient space to hold n integers. Duplicates are allowed, as





5. (20 points) This problem considers your MinHeap implementation. Suppose it has been instantiated with sufficient space to hold n integers. Duplicates are allowed, as usual In terms of the code we used for lab, the name of the array representing the binary tree is array, and we have n = size array.length > size We will consider below some operations on the heap we have not previously seen. You may express your solution in code, in pseudocode, or in prose, but you must be clear and precise about what you are doing in your solutions. You will not be penalized for syntax problems. (a) (6 points) reduceToParent (int loc): the heap value at array index loc is decreased to the heap value of loc's parent. i. Complete the inquality below to indicate exactly those values for loc that are valid for this operation to work: i. Below describe your implementation for this method. Be sure that when your method is finished, the heap is in a valid state. iii. If the heap has n elements, your approach takes ( ) time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
