Data Structures | Heap | Question 3
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, a[0], nodes in the next level, from left to right, is stored from a[1] to a[3]. The nodes from the second level of the tree from left to right are stored from a[4] location onward. An item x can be inserted into a 3-ary heap containing n items by placing x in the location a[n] 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?
(A) 1, 3, 5, 6, 8, 9
(B) 9, 6, 3, 1, 8, 5
(C) 9, 3, 6, 8, 5, 1
(D) 9, 5, 6, 8, 3, 1
Answer: (D)
Explanation: Following 3-ary Max Heap can be constructed from sequence given option (D)
9
/ | \
/ | \
5 6 8
/ |
/ |
3 1
Recommended Posts:
- Data Structures | Heap | Question 2
- Data Structures | Heap | Question 5
- Data Structures | Heap | Question 6
- Data Structures | Heap | Question 7
- Data Structures | Heap | Question 1
- Data Structures | Heap | Question 11
- Data Structures | Heap | Question 8
- Data Structures | Heap | Question 4
- Data Structures | Heap | Question 12
- Data Structures | Heap | Question 9
- Data Structures | Heap | Question 12
- Introduction to Data Structures | 10 most commonly used Data Structures
- Data Structures | B and B+ Trees | Question 2
- Data Structures | B and B+ Trees | Question 1
- Data Structures | Misc | Question 3



