retagged by
8,941 views
32 votes
32 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

  1. $4$
  2. $5$
  3. $2$
  4. $3$
retagged by

4 Answers

Best answer
37 votes
37 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.

edited by
4 votes
4 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.
3 votes
3 votes

3  interchanges needed to convert it into a max-heap

Answer:

Related questions

36 votes
36 votes
4 answers
1
go_editor asked Feb 14, 2015
9,204 views
Given that hash table $T$ with $25$ slots that stores $2000$ elements, the load factor $a$ for $T$ is _________.
25 votes
25 votes
8 answers
2
go_editor asked Feb 14, 2015
7,254 views
While inserting the elements $71, 65, 84, 69, 67, 83$ in an empty binary search tree (BST) in the sequence shown, the element in the lowest level is$65$$67$$69$$83$
23 votes
23 votes
3 answers
3
Kathleen asked Sep 22, 2014
13,638 views
Consider a binary max-heap implemented using an array.Which one of the following array represents a binary max-heap?$\left\{25,12,16,13,10,8,14\right\}$ $\left\{25,14,...
27 votes
27 votes
3 answers
4
Kathleen asked Sep 18, 2014
5,585 views
The elements $32, 15, 20, 30, 12, 25, 16,$ are inserted one by one in the given order into a maxHeap. The resultant maxHeap is