Question 71Asked in DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1

Which of the following is a max-heap?

  1. ARoot 100; children 80 and 60; 80 has child 40; 60 has children 50 and 30; 50 has child 20.
  2. BRoot 100; children 80 and 60; 80 has children 40 and 50; 60 has children 20 and 30.
  3. CRoot 100; children 80 and 60; 80 has children 40 and 50; 60 has right child 30; 30 has child 20.
  4. 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

This is question 71 of DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.