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 (414k points) | 887 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.8k 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 (283 points)

Related questions

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
49,814 questions
54,518 answers
75,287 users