in DS recategorized
804 views
1 vote
1 vote

Which of the following is a valid heap?

 

  1. $a$
  2. $b$
  3. $c$
  4. $d$
in DS recategorized
804 views

7 Answers

7 votes
7 votes

all option are false

Option A is violated max heap property because 8 is greater than his root.
Option B  is violated max heap property because 8 is greater than his root.
Option C is violated max heap property because 7 is greater than his root.
Option D is violated max heap property because 9,10,8,7 elements are greater than his root.

3 votes
3 votes

OPTION (B) This is only tree which follows the property of max heap.

3 votes
3 votes
In binary search tree root is greater than left Subtree and less than right subTree but in heap there are two cases

Case1:Max heap:Root is maximum in this if not then we have to heapify

Case 2:Min heap:Root is minimum in this if not then we have to do heapify

A) no because of 4

B) yes

C) no because of 1

D) same as c

So option b

1 comment

Option A and B are same
0
0
1 vote
1 vote
A , D , C are invalid

As there are child>parent case

A: 8>4

C: 7>1

D: 10>3

only B is valid heap... parents>children

1 comment

This is the case of a max heap. in min heap parent < child
0
0
Answer:

Related questions