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........... Data Structures data-structures binary-heap numerical-answers + – Ashwani Kumar 2 4.9k views answer comment Share Follow Print See all 21 Comments 21 21 Comments reply Show 18 previous comments `JEET commented Nov 24, 2018 reply Follow flag Yeah..exactly. Spot on :D Thanks. 0 0 replyShare Prateek Raghuvanshi commented Nov 26, 2018 reply Follow flag It could be helpful. 5 5 replyShare mehul vaidya commented Feb 17, 2019 i edited by mehul vaidya Feb 17, 2019 reply Follow flag I understood answer I have very basic doubt Given number , what is formulae to find it's level I know this is very basic , but I am struggling to find one for this example , assuming we haven't twisted graph and drawn just in sequence 1,2,3,4,5,1023 in this increasing order only. 0 0 replyShare Please log in or register to add a comment.
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 Aakash_ answered Oct 26, 2018 Aakash_ comment Share Follow 0 reply Please log in or register to add a comment.
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 DevKant Sharma answered Nov 13, 2018 DevKant Sharma comment Share Follow 0 reply Please log in or register to add a comment.