Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Data Structures | Heap | Question 5

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Consider a binary max-heap implemented using an array. Which among the following arrays represents a binary max-heap? 
(More than one option correct)

(A)

25,12,16,8,10,13,14

(B)

25,12,16,13,10,8,14

(C)

25,14,16,13,10,8,12

(D)

25,14,12,13,10,8,16



Answer: (A) (C)

Explanation:

A tree is max-heap if data at every node in the tree is greater than or equal to it’s children’ s data. In array representation of heap tree, a node at index i has its left child at index 2i + 1 and right child at index 2i + 2. 

For Example :-

           25
        /      \\
      /          \\
    14            16
   /  \\           /  \\
 /      \\       /     \\
13     10      8       12

So, the correct answer are A and C.


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

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads
Related Tutorials