

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


designed by Matt V 2010
Trace the following code segments and show the output.
list
for (int j = 0; j < 6; j++) { numbers.insert(numbers.end(), k); k--; }
list
for (i = numbers.begin(); i != numbers.end(); i++) { cout << *i << endl; }
deque
for (int i = 1; i < 6; i++) { deqExample.push_front(k + 1); k++; }
deqExample.pop_front(); deqExample.pop_front();
for (int i = 0; i < deqExample.size(); ++i) { cout << deqExample[i] << ' '; }
stack
while (stackExample.size() != 0) { cout << stackExample.top() << " "; stackExample.pop();
set
for (i = setExample.begin(); i != setExample.end(); i++) cout << *i << " ";
list
for (int j = 0; j < 5; j++) { numbers.insert(numbers.end(), num); num++; }
numbers.pop_front(); numbers.reverse(); list
for (i = numbers.begin(); i != numbers.end(); i++) cout << *i << endl;
priority_queue
while (!pq.empty()) { cout << pq.top() << " "; pq.pop(); }
deque
for (int i = 1; i <= 6; i++)