A 3 way (ternary) min heap is a 3 way ( ternary – each node as atmost three children nodes, left, mid, right ) complete tree with min heap property ( value of the parent is less than the value of the children ) satisfied at every node. Given a ternary heap in the array representation.
(a) Write the following functions.
- Parent(i) // returns the index of the parent of i
- Leftchild(i) // returns the index of the left child of i
- Middlechild(i) // returns the index of the Middle child of i
- Rightchild(i) // returns the index of the right child of i
(b) Write the pseudocode for the topdownheapify function.
(c) In Heapsort, binary heap is preferred over ternary heap. State if this statement is true or false, you must justify your answer.