retagged by
2,685 views
0 votes
0 votes

Consider a binary min-heap containing $105$ distinct elements. Let $k$ be the index (in the underlying array) of the maximum element stored in the heap. The number of possible values of $k$ is

  1. $53$
  2. $52$
  3. $27$
  4. $1$ 
retagged by

2 Answers

1 votes
1 votes
A binary heap is a complete binary tree.

A binary min-heap satisfies min-heap property. This implies that the maximum element can be in the leaves only.

No. of internal nodes in 105 element heap = $floor(\frac{105}{2}) = 52$.

No. of leaves = 105 - 52 = 53.

Answer - A
0 votes
0 votes

its Actually pretty easy. 

Just remember that the number of leaf nodes in any Complete Binary Tree is given by the formula

ceil( Total no. of nodes/2) , which is in this case, 53 where each element is a node. 

Maximum element is bound to be among the leaf nodes only. That is a common sense. If it was at 2nd last level, it cannot be Maximum element. 

Answer:

Related questions

0 votes
0 votes
2 answers
1
rishu_darkshadow asked Sep 26, 2017
1,317 views
In a heap, every element is ___________ of all the elements in the subtree.maximum minimum sum product
28 votes
28 votes
1 answer
3
makhdoom ghaya asked Feb 13, 2015
7,063 views
Consider a max heap, represented by the array: $40, 30, 20, 10, 15, 16, 17, 8, 4$.$$\begin{array}{|l|l|}\hline \text{Array index} & \text{1} & \text{2} & \text{3} & \...
14 votes
14 votes
4 answers
4
Arjun asked Feb 18, 2021
9,091 views
​​​​​Let $H$ be a binary min-heap consisting of $n$ elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the...