Question: 4 . ( 2 5 points ) a . Given the array representation of the heap data structure, write the pseudocode implementations of the three

4.(25 points) a. Given the array representation of the heap data structure, write the pseudocode implementations of the three basic operations defined for min-heap based priority queues, i.e. priority queues which are based on the heap data structure intemally, and where lower numerical values indicate higher priorities;
- Initialize(n): initializes and returns an Initially empty array based heap that can hold a maximum of n elements.
- DeleteMin(H[1..n]): Defetes and returns from the given min-heap based priority queue the element with the highest highest priority.
- Insert(H[1..n]element, priority): Inserts the given element with the given prionity to the given min-heap based priority queve.
- DocreasePtiority(H[1.n],element, amount): Decreases the prionity of the given element in the givan min-heap based priority queue with the given amount (you can assume that the element is already in the priority queue).
b. Using the operations you defined in part a above, revise the pseudocode given during the last lecture for Prim's Minimum Spanning Tree (MST) implementation (Week13 SlideH20) to use a priority queve based on the min-heap data structure, rather than a regular (unordered) array based representation. The input Graph to the algorithm should also be represented as an adjacency list, rather than the adjacency matrix representation given in the class, i.,e.;
Algorithm Prim(Ad][D..n-1))
//Input: Adjacency list representatin of \( G \)//Output: Total weight of the MST of G \(\mathrm{mst}\leftarrow 0\)
....
return mst
Perform a time complexity analysis of your algorithm, based on the number of vertices IVI and number of edges |E| in the Graph.
As a fast reminder of adjacency Jist representation of graphs; and a basic pseudocode on how to process them is given below:
4 . ( 2 5 points ) a . Given the array

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 Programming Questions!