1 votes 1 votes Consider a binary min heap containing n elements and every node is having degree 2 ( i.e. full binary min heap tree). What is the probability of finding the largest element at the last level ? According to my understanding the largest element has to be a leaf and since leafs can be on two levels last and second last therefore the probability should be 1/2 DS data-structures binary-heap geeksforgeeks-test-series + – Pankaj Joshi asked Jan 14, 2017 • recategorized Jul 6, 2022 by Lakshman Bhaiya Pankaj Joshi 2.2k views answer comment Share Follow See all 19 Comments See all 19 19 Comments reply Show 16 previous comments Rahul Jain25 commented Jan 19, 2017 reply Follow Share I have read all comments and you need to understand difference between full tree and complete tree. Question has given full tree you search on google about full tree. Answer is 1. And they have asked about level and not left or right subtree. So maximum is always at last level. 1 votes 1 votes Pankaj Joshi commented Jan 19, 2017 reply Follow Share https://en.wikipedia.org/wiki/Binary_tree 0 votes 0 votes joshi_nitish commented Jul 13, 2017 reply Follow Share @pankaj...since max can be present in last two levels, we can say that, P(last level)+P(second last level)=1, but how you are concluding that P(last level)=P(second last level) and hence P(last level)=1/2... it will depend on nos of leaves present in last level and second last level... 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes By Constructing a min Heap , we can say that the maximum element can be any where in the last level. There is not any possibility that any internal node contains the maximum element. So probability of getting maximum element at leaf level is 1. Arnab Bhadra answered Jun 20, 2017 Arnab Bhadra comment Share Follow See 1 comment See all 1 1 comment reply smsubham commented Dec 27, 2017 reply Follow Share Also, key values should be unique. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes there is ambigutiy... if leaf is in 2 levels than p=0.5 and if it is in last level p=1...that depends on value of n. nitish1995 answered Apr 5, 2017 nitish1995 comment Share Follow See all 0 reply Please log in or register to add a comment.