Open In App

Data Structures | Heap | Question 2

Like Article
Like
Save Article
Save
Share
Report issue
Report

A max-heap is a heap where the value of each parent is greater than or equal to the values of its children. Which of the following is a max-heap? (GATE CS 2011) .

 


(A)

A

(B)

B

(C)

C

(D)

D



Answer: (B)

Explanation:

(A) The provided tree is not a complete tree. 
(B) The tree is a max-heap, as the root element is greater than all of its children elements.

  • 10  > 8 and 6
  • 8   > 4 and 5
  • 6  > 1 and 2

(C) In the given tree, the Left root value 5 is smaller than 8, which is not following the constraints.
(D) In the given tree, the root value 5 is smaller than 8, which dissatisfies the condition.

Hence (B) is the correct Option. 


Quiz of this Question
Please comment below if you find anything wrong in the above post


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads