0 votes 0 votes Consider the following array of elements <96,42,50,17,15,5,7,11,39,23,6,9,19,100,12> The minimum number of interchanges using buildheap needed to convert it into a max heap is DS data-structures binary-heap made-easy-test-series + – amitarp818 asked Nov 28, 2023 • recategorized Nov 29, 2023 by Hira Thakur amitarp818 650 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Hira Thakur commented Nov 29, 2023 reply Follow Share $1$ swap for $11\rightarrow39$ $1$ swap for $15\rightarrow 23$ $1$ swap for $5\rightarrow9$ $1$ swap for $9\rightarrow19$ $3$ swap for $7\rightarrow100;50\rightarrow100;96\rightarrow100$ Total swap required =$1+1+1+1+3=7$ 1 votes 1 votes amitarp818 commented Nov 29, 2023 reply Follow Share @prajjwal_191 I did not understand how they randomly just swapped the elements in the end@Hira Thakur your answer is more convincing if we consider the direction from left to right. thankyou 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes I hope you got it thankyou. prajjwal_191 answered Nov 28, 2023 1 flag: ✌ Edit necessary (Bhavesh21) prajjwal_191 comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments prajjwal_191 commented Nov 29, 2023 reply Follow Share @Hira Thakur yupp mistakenly I wrote 17 as 7. Thank you for figuring it out. 1 votes 1 votes Bhavesh21 commented Jan 12 reply Follow Share so is 7 correct or 6 is correct answer? 0 votes 0 votes prajjwal_191 commented Jan 12 reply Follow Share 6 0 votes 0 votes Please log in or register to add a comment.