recategorized
2,564 views
1 votes
1 votes

A priority queue is implemented as a max-heap. Initially, it has five elements. The levelorder traversal of the heap is as follows :

20, 18, 15, 13, 12

Two new elements ‘10’ and ‘17’ are inserted in the heap in that order. The level-order traversal of the heap after the insertion of the element is :

  1. 20, 18, 17, 15, 13, 12, 10
  2. 20, 18, 17, 12, 13, 10, 15
  3. 20, 18, 17, 10, 12, 13, 15
  4. 20, 18, 17, 13, 12, 10, 15
recategorized

1 Answer

0 votes
0 votes
Answer is D

The heap is
              20
    18               15

13     12        

On inserting 10 it becomes

                20

       18               15

 13       12       10

On inserting 15


               20

      18            17

13      12      10      15

Which is
20 18 17 13 12 10 15

Related questions

1 votes
1 votes
1 answer
1
1 votes
1 votes
4 answers
2
1 votes
1 votes
1 answer
3
makhdoom ghaya asked Oct 1, 2016
866 views
Consider a hash table of size $m = 10000$, and the hash function $h(K) = floor (m(KA \bmod 1))$ for $A = ( \sqrt{5} – 1)/2$. The key $123456$ is mapped to location ____...
0 votes
0 votes
2 answers
4
makhdoom ghaya asked Sep 15, 2016
5,893 views
What is the most appropriate data structure to implement a priority queue ?HeapCircular arrayLinked listBinary tree