1 votes 1 votes It should be 5 according to me.Pleas explain if they are correct. DS made-easy-test-series data-structures binary-heap + – Lucky sunda asked Jan 8, 2017 recategorized Mar 6, 2019 by adeebafatima1 Lucky sunda 598 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply air1 commented Jan 8, 2017 reply Follow Share Delete root. Put 196 as root. Compare it with its two children 120 and 130. Swap 120 and 196. Compare with 140 and 150. Swap 196 and 140. Compare with 180 and 190. Swap 196 and 180. 6 comparisons. Anything wrong with this? 1 votes 1 votes Lucky sunda commented Jan 9, 2017 reply Follow Share arre..I did a mistake in solving..First time I replaced 130, and then 170. So 5 were coming. Yes u r correct. Thanks :) 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes ans is 5 only. shayal chhabra answered Jan 8, 2017 shayal chhabra comment Share Follow See all 11 Comments See all 11 11 Comments reply Lucky sunda commented Jan 8, 2017 reply Follow Share ok..thanks :) 0 votes 0 votes sachin! commented Jan 8, 2017 reply Follow Share 6 is correct ans 1 votes 1 votes shayal chhabra commented Jan 9, 2017 reply Follow Share can u explain how? 0 votes 0 votes saurabh rai commented Jan 9, 2017 reply Follow Share ^how to know that which is last level. 0 votes 0 votes Lucky sunda commented Jan 9, 2017 reply Follow Share first we will exchange 196 and root. Then 120 and 196.Now childeren of 196 are 140 and 150. So, 196 and 140 are exchanged.Now childeren of 196 are 180 and 190. And now finally 196 and 180 are excahnged.We cannot go further so, this is the last level. I think u asked this only? 0 votes 0 votes saurabh rai commented Jan 9, 2017 reply Follow Share i m only want 2 say in these type of questions we have an algorithm 2 apply on the problem nd that algorithm yields no of comparisons. like here we ll apply delete algorithm on root . now if u r doing like that just before last level it will require atmost 1 comparison nd for all others 2 comparison.so for this type of procedure every time we need 2 check for last level that ll also increases cost may b in terms of no.of comparisons. 0 votes 0 votes Lucky sunda commented Jan 9, 2017 reply Follow Share But at last level here, It is doing two comparisons. We have to just check that the node has two childeren and then compare with them, orelse one child orelse it is a leaf. But these things are had to be done in nearly all tree algorithms, and these steps are not increasing any comparisons here. 0 votes 0 votes saurabh rai commented Jan 9, 2017 reply Follow Share acc 2 u is it correct r nt? Delete root. Put 196 as root. Compare it with its two children 120 and 130. Swap 120 and 196. Compare with 140 and 150. Swap 196 and 140. Compare with 180 and 190. Swap 196 and 180. 6 comparisons. 0 votes 0 votes Lucky sunda commented Jan 9, 2017 reply Follow Share yes..it is correct according to me. 0 votes 0 votes saurabh rai commented Jan 9, 2017 reply Follow Share srry i think u r thinking 5 as corrrect ans i m explaining abt why 5 is nt correct just a conflict.:) 0 votes 0 votes Lucky sunda commented Jan 9, 2017 reply Follow Share oh..Actually someone cleared it above.. thanks for ur effort :) 0 votes 0 votes Please log in or register to add a comment.