Declare a stack-queue and priority queue


Discuss the below:

Q: Declare a stack, queue, and priority queue of integers, as follows:

stack s;
queue q;
priority_queue pq;

Assume that you input the integer sequence

5 8 12 15 1 3 18 25 18 35 2 55

and insert each value into each container in the order given. What is the output of the following statements?

while (!s.empty())
{
cout << setw(5) << s.top() << setw(5)
<< q.front() << setw(5)
<< pq.top() << endl;
s.pop(); q.pop(); pq.pop();
}

 

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Declare a stack-queue and priority queue
Reference No:- TGS01937568

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)