The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
0 votes

Which of the following is a valid heap?

  1. A
  2. B
  3. C
  4. D
asked in Others by Veteran (353k points) | 649 views

2 Answers

+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
answered by Active (3.9k points)
This is the case of a max heap. in min heap parent < child
0 votes
A heap is a complete binary tree with special property that value of child nodes is either less or greater than their parent. Two types of Heaps are:

1. Max Heap: where value of parent node is greater than its child nodes (by default)

2. Min Heap: where value of parent node is less than its child nodes

In the given question, all cases are of max heap.

A is NOT valid heap as, 8>4 is there

C is NOT valid heap as, 7>1 is there

D is NOT valid heap as, 7>1 and 8>4 is there

Therefore, B is a valid heap.
answered by (231 points)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

37,116 questions
44,699 answers
43,761 users