Question: For this question, assume the definition of Java class Heap given in the Appendix. The heaps referred to in this question are all maxHeaps. a.

 For this question, assume the definition of Java class Heap given

For this question, assume the definition of Java class Heap given in the Appendix. The heaps referred to in this question are all maxHeaps. a. Insert into an empty (binary) heap the values 35, 4, 72, 36, 49, 50. Draw all intermediate steps. b. Carry out one deletion operation on the final heap in (a.) above. c. Give the worst-case time complexity of insertion and deletion operations for a heap with a elements, and justify this complexity (in two sentences or so). d. Imagine a variation to the binary heap of lectures called terHeap, where instead of each node having two children, it has three children. The tree is still required to be complete, and the heap property that the parent is at least as large as its children must be maintained. An example of a terHeap is as follows: There is similarly an array representation: Call the children of each node leftChild, midChild, and rightChild. What are the equations that relate the index of a node to the indices of its children in this array representation? e. Using your answer to (d.) above or otherwise, modify the code for heapRebuild (in the Appendix) to handle terHeaps rather than regular binary heaps. You should write out the full code in the answer book. (You may leave out the comments from the original code.) f. Imagine a further generalisation of the heap, so that rather than the standard Heap where each node has two children, or the terHeap of (d.) where each node has three children, you have an naryHeap where each node has n children (subject to being a complete tree). In the original heapRebuild. the children are represented and processed by variables child and rightChild. For an naryHeap's heapRebuild, describe a possible representation for

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!