GATE / CS ARCHIVE

GATE CSE 1991 / QUESTION 14(a)

Identifying the tree structure

Data Structures · Heaps & Priority Queues · Full GATE CSE 1991 paper

GATE 1991, Q14(a) 1 mark · Descriptive
Report issue

Heaps & Priority Queues

Question 14(a), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Identify the data structure.
Question 14(a), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Identify the data structure.
Question 14(a), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Identify the data structure.
Tap to enlarge
Answer & solution

Answer: A binary min-heap. (no official key was published)

Two separate conditions identify this tree. First, its shape is complete: all levels above the last are full and the last level fills from left to right. Second, every parent is no greater than either child: for example 1≤5,18; 5≤7,13; 18≤25,20; and 7≤11,9. The minimum element is therefore at the root, and the tree is a binary min-heap.

It is not a binary search tree. For instance, the root's left subtree contains 5 even though 5>1, and the left child 25 of node 18 exceeds its parent. A heap imposes parent-child order but imposes no sorted order between siblings or across unrelated subtrees. The level-order array in the prompt fully specifies the source figure and provides the customary compact heap representation.

Original paper, page 8