retagged by
15,418 views
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

  1. $4$
  2. $5$
  3. $2$
  4. $3$

4 Answers

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.

edited by
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.
Answer:
Position:
Show:

Related questions

49 49 votes
5 answers 5 answers
14.9k
14.9k views
go_editor asked Feb 14, 2015
14,916 views
Given that hash table $T$ with $25$ slots that stores $2000$ elements, the load factor $a$ for $T$ is _________.
34 34 votes
8 answers 8 answers
12.7k
12.7k views
go_editor asked Feb 14, 2015
12,705 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$
34 34 votes
7 answers 7 answers
19.9k
19.9k views
go_editor asked Feb 14, 2015
19,850 views
The result evaluating the postfix expression $10 \ 5 + 60 \ 6 / * 8 -$ is $284$$213$$142$$71$
36 36 votes
1 answers 1 answer
11.0k
11.0k views
Misbah Ghaya asked Feb 13, 2015
11,017 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} & \...