2 votes 2 votes For the given nodes: $89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100$ minimum ______ number of interchanges are required to convert it into a max-heap. $3$ $4$ $5$ $6$ DS nielit-2018 data-structures binary-heap + – Arjun asked Dec 7, 2018 retagged Oct 28, 2020 by Krithiga2101 Arjun 1.4k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
4 votes 4 votes Taking the given nodes as level order traversal, we can build the following binary tree Now the max heap property is failing on vertices $15$ and $100$ After swapping, tree is Now the max heap property is failing on vertices $50$ and $100$ After swapping, tree is Now the max heap property is failing on vertices $89$ and $100$ After swapping, tree is The above tree is the final max heap binary tree. Minimum number of interchanges are $3$ Correct answer: $A$ Shiva Sagar Rao answered Aug 12, 2019 edited Oct 28, 2020 by Shiva Sagar Rao Shiva Sagar Rao comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes 1st swap is: 100 and 15 2nd swap is: 100 and 50 3rd swap is: 100 and 89 topper98 answered Mar 18, 2020 topper98 comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes CREATE BINARY TREE STEP 1 :- EXCHANGE 100 AND 15 STEP 2 :- EXCHANGE 100 AND 50 STEP 3 :- EXCHANGE 100 AND 89 MAX HEAP IS COMPLETED ANSWER IS 3 Arpit123 answered Oct 28, 2020 Arpit123 comment Share Follow See all 0 reply Please log in or register to add a comment.