Question: (a) Consider storing a heap as a linked binary tree with pointers. Give pseudocode on how you would store a heap node, and which modifications

(a) Consider storing a heap as a linked binary tree with pointers. Give pseudocode on how you would store a heap node, and which modifications you need to make to the heap routines that we discussed in class. What are the runtimes of the heap routines?

(b) Now consider storing a heap as a linked list with pointers. Give pseudo-code on how you would store a heap node, and which modifications you need to make to the heap routines that we discussed in class. What are the runtimes of the heap routines?

(c) Which of the three heap implementations (array, linked tree, linked list) is preferrable? Justify your answer.

(d) Assume you are given two heaps of height h each, that are given as linked binary trees. And assume we do not require that the last level of the heap is flushed left, i.e., keys can be in any place in the last level. Give an efficient algorithm that merges those two heaps into one heap (without the flushed left condition). Analyze the runtime of your algorithm.

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