A max-heap is a heap where the value of each parent is greater than or equal…

2011

A max-heap is a heap where the value of each parent is greater than or equal to the value of its children. Which of the following is a max-heap?

Attempted by 395 students.

Show answer & explanation

Key properties to check for a max-heap:

  • Heap-order property: every parent node's value must be greater than or equal to the values of its children.

  • Completeness: a heap is usually represented as a complete binary tree (levels filled left-to-right).

Why the correct tree is a max-heap:

  • Check the heap-order property for the chosen tree: 10 ≥ 8 and 6; 8 ≥ 4 and 5; 6 ≥ 1 and 2. All parent nodes are greater than or equal to their children.

  • Check completeness: the tree is filled level-by-level from left to right with no gaps.

Conclusion: This tree satisfies both the heap-order property and completeness, so it is a valid max-heap.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir