retagged by
9,080 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,316 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,373 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$
28 votes
28 votes
1 answer
3
makhdoom ghaya asked Feb 13, 2015
6,990 views
Consider a max heap, represented by the array: $40, 30, 20, 10, 15, 16, 17, 8, 4$.$$\begin{array}{|l|l|}\hline \text{Array index} & \text{1} & \text{2} & \text{3} & \...
42 votes
42 votes
12 answers
4
go_editor asked Feb 14, 2015
24,270 views
Consider a binary tree T that has $200$ leaf nodes. Then the number of nodes in T that have exactly two children are ______.