Computer Science Homework Solutions
Problem
#133925

Data Structures with C++ Using STL

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();
         }



Please provide a complete program if it makes sense.

Attached file(s):
Attachments
8.17.doc  View File

Attachment Content Summary (Note: view attachment at the above link before purchasing. Actual attachment content may vary slightly from that shown below.)

8.17.doc
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();

}

Please provide a complete program if it makes sense.

Solution Summary

A stack, queue, and priority queue of giving integers are declared.

Solution
What is this?
By OTA - Overall OTA Rating
Purchase Cost Now
$2.19 CAD (was ~$11.97)
Included in Download
  • Plain text response
  • Attached file(s):
    • q.zip
    • 8.17[1]_Answer.doc
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
Browse