Which of the following is a valid heap ?
A 16 14 10 4 7 9 3 2 8 1
B 16 14 10 8 7 9 3 2 4 1
C 16 14 10 8 1 9 3 2 4 7
D 16 14 3 4 1 9 10 8 2 7
(A)
A
(B)
B
(C)
C
(D)
D
Answer: (B)
Explanation:
For a heap to be valid, either it should be max heap or a min heap. Only B option heap is valid and it is a max heap. So, option (B) is correct.
Quiz of this Question
Please comment below if you find anything wrong in the above post
Article Tags :
Recommended Articles