Question: Use only C programming language for the following questions, only need to answer question 1 and 3 1. Write in pseudo-code the siftdown algorithm for
Use only C programming language for the following questions, only need to answer question 1 and 3
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
Get step-by-step solutions from verified subject matter experts
