Question: Use only C programming language for the following questions. 1. Write in pseudo-code the siftdown algorithm for a min-heap. 2. A ternary max-heap is similar

Use only C programming language for the following questions.

1. Write in pseudo-code the siftdown algorithm for a min-heap.

2. A ternary max-heap is similar to the binary max-heap that we have discussed in class, but now non-leaf nodes can have 3 children instead of 2.

(i) A ternary max-heap can be represented using an array. What are the indices of the parent and children of a node at index i ?

(ii) Write in pseudocode the siftdown algorithm for a ternary max-heap.

3. Show that the alogorihm in Question 2(ii) has worst-case complexity O(log n), where n is the length of 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 Databases Questions!