39 39 votes Consider the following array of elements. $\langle 89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100 \rangle$ The minimum number of interchanges needed to convert it into a max-heap is $4$ $5$ $2$ $3$ Data Structures gatecse-2015-set3 data-structures binary-heap easy + – go_editor 15.4k views answer comment Share Follow Print See all 5 Comments 5 5 Comments reply Show 2 previous comments Thadymademe commented Jul 12, 2022 reply Follow flag @ASNR1010 bro are you making collection of repeated questions?? 0 0 replyShare Kiyoshi commented Jul 12, 2022 reply Follow flag Nopes bro, I just put the links of whatever question I found repeated. So any future aspirant can see the resemblance. 🙂 9 9 replyShare js__ commented Jan 16 reply Follow flag 100 needs to be swapped with 15 then with 50 then with 89 => 3 swaps 0 0 replyShare Please log in or register to add a comment.
Best answer 44 44 votes Interchanges: 1$^{\text{st}}$ $15$-$100$ 2$^{\text{nd}}$ $50$-$100$ 3$^{\text{rd}}$ $89$-$100$ Total interchange $3$ so option (D) is correct. Anoop Sonkar answered Feb 15, 2015 • edited Jan 17, 2023 by shadymademe Anoop Sonkar comment Share Follow 0 reply Please log in or register to add a comment.
15 15 votes 3 swaps needed pankaj_vir answered Mar 24, 2018 pankaj_vir comment Share Follow 0 reply Please log in or register to add a comment.
5 5 votes We can use Build Heap or Insertion method to convert given array into max heap . In both case 3 swaps are required . Swap(100,15) Swap(50,100) Swap(89,100) So option D is correct ans. Rajesh Pradhan answered Aug 28, 2016 Rajesh Pradhan comment Share Follow See all 6 Comments 6 6 Comments reply Show 3 previous comments adarsh_1997 commented Jul 27, 2019 reply Follow flag 14 i think. 0 0 replyShare neel19 commented Jan 31, 2021 reply Follow flag How to count the no of comparisons 0 0 replyShare Pranavpurkar commented Jul 24, 2022 reply Follow flag @Sambhrant Maurya Have you counted 2 comparisons for each element from top to bottom? 0 0 replyShare Please log in or register to add a comment.
3 3 votes 3 interchanges needed to convert it into a max-heap Rohit01 answered Sep 20, 2015 Rohit01 comment Share Follow 0 reply Please log in or register to add a comment.