Question 71Asked in DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
Which of the following is a max-heap?
ARoot 100; children 80 and 60; 80 has child 40; 60 has children 50 and 30; 50 has child 20.
BRoot 100; children 80 and 60; 80 has children 40 and 50; 60 has children 20 and 30.
CRoot 100; children 80 and 60; 80 has children 40 and 50; 60 has right child 30; 30 has child 20.
DRoot 100; children 50 and 60; 50 has children 40 and 80; 60 has children 20 and 30.
Show answerHide answer
Correct answer: (B) Root 100; children 80 and 60; 80 has children 40 and 50; 60 has children 20 and 30.
Explanation
A max-heap must be a complete binary tree with every parent ≥ its children. Option B satisfies both. A and C are not complete trees, and in D the node 50 has a larger child 80.
From DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 1