Question: Stacks and Queues Implementing a queue using stacks in C++ Implement queues using stacks Coding exercise. In this exercise, you will implement a queue using
Stacks and Queues Implementing a queue using stacks in C++
Implement queues using stacks Coding exercise. In this exercise, you will implement a queue using two stacks.
1. Create a template called
template
class stackQueue {1}; in a file called stackQueue.h
with two fields of type stack (you can use the STL stack here. If you want to use your own implementation, that is fine too). Other fields should not store queue elements. Note that the stacks can only support push and pop operations to add/remove items from the data structure. You may use auxiliary data structures within the member functions.
2. The template should support the following functionality:
a. void enqueue (elemType element) insert an element at the back of the queue
b. elemType dequeue () remove the element from the front of the queue and return the value
c. elemType front () return the value at the front of the queue. Do not delete it.
d. int size () returns the size of the queue
e. bool isEmpty () returns true if queue is empty, false if not
f. bool isFull () returns true if queue is full, false if not (Does this ever return true?)
3. Write the pseudocode and the time complexity in big-O notation for each of the above operations in a file called stackQueue.pdf. Please explain your design choices as well.
4. Implement the pseudocode in the template in stackQueue.h.
5. Test your code using main.cpp. A sample main.cpp is provided to you. You are required to edit it and test for other cases as well.
(Note any useful tips and links used to help create the code would be a big help)
main.cpp
#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
