Question: (a) List all structures that are both heaps and binary search trees. Assume that all elements of the structures have different values. (b) Use the

(a) List all structures that are both heaps and binary search trees. Assume that all elements of the structures have different values.

(b) Use the linear-time heap creation algorithm to create a heap out of the following keys: 10 12 1 14 6 5

(c) Consider that you have a class named Heap that preserves a heap of integers using an array of int - elements and an int variable named count. Write a Heap method named isCorrect to check that the heap is correctly built.

(d) Write a Heap method named incrementPriority that, given the position of an element in the array just described, adds 1 to its value and reorganizes the heap if necessary. The reorganization should require no more than O(log n) operations, where n is the current number of heap elements.

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