1-Given the binary min-heap A = [1, 60, 18, 83, 97, 68, 47, 99] do the following: (a) Draw the tree representation. (b) Show the steps involved when inserting the element 8. (c) Show the steps...





1-Given the binary min-heap A = [1, 60, 18, 83, 97, 68, 47, 99] do the following:


(a)  Draw the tree representation.


(b)  Show the steps involved when inserting the element 8.


(c)  Show the steps involved when deleting the smallest element from A (note that we are deleting from the original heap A, not from the outcome of question 1b).


(d)Given the array [5, 93, 68, 91, 37, 11, 8, 54, 84, 19, 10, 80, 68], create a binary min-heap using the procedure MakeHeap from the lectures.


Give a sequence of arrays highlighting the two elements that get swapped in the array and draw a tree representation of the final heap.


(e)Describe (with some pseudocode) how to write an ADT that imple- ments a priority queue using a binary min-heap , and which ALSO allows changing the priority of a key.






Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here