Statement for Linked Answer Questions 76 & 77:
A 3-ary max heap is like a binary max heap, but instead of 2 children, nodes have 3 children. A 3-ary heap can be represented by an array as follows: The root is stored in the first location, , nodes in the next level, from left to right, is stored from to . The nodes from the second level of the tree from left to right are stored from location onward. An item can be inserted into a 3-ary heap containing items by placing in the location and pushing it up the tree to satisfy the heap property.
Which one of the following is a valid sequence of elements in an array representing 3-ary max heap?
GATE CSE 2006Data Structures › Heaps & Priority QueuesVerified
GATE CSE 2006 PYQ: Statement for Linked Answer Questions 76 & 77: A 3 3 3 -ary max heap is like a binary max heap, but instead…
- A
- B
- C
- DCorrect answer
Answer
(D) 9 , 5 , 6 , 8 , 3 , 1 9, 5, 6, 8, 3, 1 9 , 5 , 6 , 8 , 3 , 1
Approach
Use the array representation of a complete 3-ary max-heap. Derive the parent-child index relationships, then check each option for the max-heap property: every parent must be greater than or equal to all of its children.
Only option D satisfies the 3-ary max-heap ordering for the given complete-tree array representation.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.