recategorized by
4,872 views
5 5 votes
A min heap having 1024 distinct elements with keys ranging from 0 to 1023 is stored in array of 1024 indices. The maximum difference between the keys of all the element that can possibly be stored at (n/2)th index of the array is...........

2 Answers

1 1 vote
There are 1024 elements, there will be total 11 levels, 512 is the middle element. minimum level possible is Level 2 because 0 is the minimum element, Root should be 0, in the second level we can have 512.

 

Maximum level possible is Level 11.

 

Difference is 11-2 = 9
0 0 votes
since there are 1024 elements, there will be ceil{log(1+1024)}=11 levels, so in worst case, the 512 can be present at level 11(last level)

in best case the element  512 can be present only at level 2, it root is at level 1

then the difference = 11-2=9

Answer is 9
Position:
Show:

Related questions

4 4 votes
2 2 answers
158
158 views
GO Classes asked Jul 21
158 views
A min-heap is stored using $1$-based indexing as:$[2, 13, 7, 17, 14, 22, 8, 21]$After one $\texttt{DeleteMin}$ operation, what is the final heap array?$[7, 13, 8, 17, 14,...
0 0 votes
1 1 answer
1.0k
1.0k views
saurav raghaw asked Dec 22, 2018
1,014 views
The time complexity of the most efficient algorithm to determine whether an arbitrary array of size ‘n’, is min-heap or not?(A) O(log n)(B) O(n)(C) O(n logn)(D) O(1)
1 1 vote
1 answers 1 answer
3.3k
3.3k views
gmrishikumar asked Dec 1, 2018
3,340 views
What is the time complexity to find the Kth largest element in a Min-Heap? Or equivalently, What is the time complexity to find Kth smallest element in Max-Heap?
1 1 vote
1 1 answer
1.2k
1.2k views
iarnav asked Jun 24, 2018
1,208 views
The number of distinct min heap are possible with keys 1, 2, 3, 4, 5 are ________.I know, there are variance of this question for Max heap and even for Min heap, the answ...