Explore BrainMass
Share

C++ stack in terms of queue and symbol balancing using stack

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

1. Define a stack in terms of the queue i.e. create a class

template <class T>
Class StackQ {
Queue<T> pool;
.......................
Void push(const T& el) {
pool.enqueue(el);
.........................
}
.......................
}

2. Transfer elements from stack s1 to stack s2 so that the elements from s2 are in the same order as on s1, using one additional stack.

3. Write a program to verify symbol balancing using stack.

See the attached file.

© BrainMass Inc. brainmass.com March 21, 2019, 5:14 pm ad1c9bdddf
https://brainmass.com/computer-science/cpp/cplusplus-stack-terms-queue-symbol-balancing-stack-214055

Attachments

Solution Summary

Each of the program requirement has been implemented as a function in the attached C++ file, and a main function has also been provided to test these.

$2.19