Skip to content
Related Articles

Related Articles

UGC-NET | UGC NET CS 2016 Aug – III | Question 34

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 17 Apr, 2018

A priority queue is implemented as a max-heap. Initially, it has five elements. The level-order 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:
(A) 20, 18, 17, 15, 13, 12, 10
(B) 20, 18, 17, 12, 13, 10, 15
(C) 20, 18, 17, 10, 12, 13, 15
(D) 20, 18, 17, 13, 12, 10, 15


Answer: (D)

Explanation: Initially we have:
34 (1)
When we insert 10 and 17:
34 (2)
We have to maintain max-heap, so:
34 (3)
The level-order traversal of the heap after the insertion of the element is 20, 18, 17, 13, 12, 10, 15
So, option (D) is correct.


Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!