priority_queue
pq;
pq.push(5);
pq.push(6);
pq.push(1);
pq.push(2);
cout << pq.top() << \" \" << pq.size()<< endl;
pq.pop();
cout << pq.top() << \" \" << pq.size();
[/sourcecode]
(A) 6 5
5 4
(B) 6 5
5 3
(C) 6 4
5 3
(D) None of the mentioned
Answer: (C)
Explanation:
top(): returns reference to the topmost of the queue but does not removes it from the queue.
Hence the size remains same.
But pop(): returns the topmost element and removes from the queue as well.
Hence the size decreases.
Quiz of this Question
Share your thoughts in the comments
Please Login to comment...