The GATE Grind

GATE 2011 CS (CS1) – Question 33

Programming and Data Structures · Binary Heaps · 1 mark · Multiple choice

A max-heap has parent values at least their children’s values. Which displayed tree is a max-heap?

Diagram for GATE 2011 CS (CS1) question 33
  1. Tree A
  2. Tree B
  3. Tree C
  4. Tree D

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (B) Tree B

Explanation

A heap must also be a complete binary tree; A violates completeness. C has child eight below parent five, and D has children exceeding their parents. B is complete and satisfies every parent-child comparison. Therefore B.

More Binary Heaps questions

All Binary Heaps questions →