The Gateway to Computer Science Excellence
+15 votes

Consider a binary max-heap implemented using an array.
Which one of the following array represents a binary max-heap?

  1. $\left\{25,12,16,13,10,8,14\right\}$    
  2. $\left\{25,14,13,16,10,8,12\right\}$
  3. $\left\{25,14,16,13,10,8,12\right\}$
  4. $\left\{25,14,12,13,10,8,16\right\}$
in DS by Veteran (52.2k points)
retagged by | 1.7k views

3 Answers

+12 votes
Best answer

Answer : (C)

The binary max-Heap looks like this :



by Junior (911 points)
edited by
+18 votes
Taking the given array as level order traversal, we can build binary tree.

(A)  13 comes as child of 12, which is not allowed in a binary max-heap

(B) 16 comes as child of 14 violating max-heap property

(C) is a valid binary max-heap as all children are smaller than their parent

(D) 16 comes as child of 12, violating max-heap property
by Veteran (431k points)
0 votes

option c is right

by Boss (36.5k 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
50,737 questions
57,292 answers
104,910 users