Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include stackQueue.h using namespace std; int main() { try{ stackQueue charQueue; charQueue.enqueue('A'); charQueue.enqueue('B'); cout charQueue.enqueue('C'); cout charQueue.enqueue('D'); cout cout cout } catch(const char *e)
#include
#include "stackQueue.h"
using namespace std;
int main() {
try{
stackQueue charQueue;
charQueue.enqueue('A');
charQueue.enqueue('B');
cout
charQueue.enqueue('C');
cout
charQueue.enqueue('D');
cout
cout class stackQueue (.. 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. The template should support the following functionality 2. 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 ifqueue is full, false if not (Does this ever return true?) 3. Write the pseudocode and thetime 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 usingmain.cpp. A sample main.cpp is provided to you. You are required to edit it and test for other cases as well. What to turn in A zip file containing the files stackQueue.h, stackQueue.pdf, and main.cpp files. In stackQueue.pdf, cite all the sources you referred to including code you referenced on the Internet
cout
Coding exercise In this exercise, you will implement a queue using two stacks. 1. Create a template called template }
catch(const char *e) {
cout
}
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started