Explore BrainMass

Explore BrainMass

    Data Structure in C++ Using STL

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

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

    stack<int> s;
    queue<int> q;
    priority_queue<int> 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.

    © BrainMass Inc. brainmass.com November 30, 2021, 1:52 am ad1c9bdddf


    Solution Summary

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