Write some Software
$10-30 USD
Paid on delivery
Practice using stacks and queues. First, you will use two stacks to implement a queue. You will implement all of the basic functions of a queue container:
push: add an element onto the end of the queue (remember that a queue has a FIFO structure)
pop: remove the element at the front of the queue
front: look at the front element
back: look at the back element
size: check the queue's size
empty: check if the queue is empty
swap: given another queue, swap all elements with the other queue
You can use the std::stack container (reference: [url removed, login to view]) in order to implement your queue. The basic idea is that you will have one stack to take in your inputs, and another stack you will use to output values. Here is the basic pseudo code for enqueuing and dequeuing an element:
Enqueue: push element onto input stack
Dequeue: if output stack is not empty, pop element from output stack. Otherwise, pop elements from input stack and push them onto output stack. Then you can pop elements output stack
Once you have implemented your queue class, you should be able to run this main code with no issues. YOU NEED TO FINISH THE MAIN PROGRAM BY ADDING CODE THAT FINDS THE MIN AND MAX OF q3 IN THE FOLLOWING PROGRAM:
int main(){
myQueue<int> q1, q2, q3;
vector<int> a = {2, 4, 1, 7, 8, 9 ,0}, b = {1, 0, 4, 3, 8, 9, 10, 13, 7, 6, 5, 14, 11};
for(int i = 0; i < [url removed, login to view](); ++i){
[url removed, login to view](a[i]);
}
for(int i = 0; i < [url removed, login to view](); ++i){
[url removed, login to view](b[i]);
}
cout<< "Initial Queue:"<<endl;
while(![url removed, login to view]()){
cout << [url removed, login to view]() << " " ;
[url removed, login to view]([url removed, login to view]());
[url removed, login to view]();
}
cout<<endl<<"Size of Q3 (Q1 Reversed): "<<[url removed, login to view]()<<endl;
cout<<"Back element of Q3: "<<[url removed, login to view]()<<endl;
[url removed, login to view](q2);
cout<<endl<<"Size of Q3 (after swap): "<<[url removed, login to view]()<<endl;
cout<<endl<<"Size of Q2 (after swap): "<<[url removed, login to view]()<<endl;
//Implement min max code here for q3
}
The output for the above main program after your min/max implementation should be should be:
Initial Queue:
2 4 1 7 8 9 0
Size of Q3 (Q1 Reversed): 7
Back element of Q3: 0
Size of Q3 (after swap): 13
Size of Q2 (after swap): 7
Max of Q3 = 14
Min of Q3 = 0
Project ID: #7417962
About the project
Awarded to:
5 freelancers are bidding on average $22 for this job
hy sir I am computer sciences graduate.I'm available for this job will surely do this job please give me a chance to prove my skills will give you 101% quality work waiting for your response regards hussain
Programming is my passion and i do work with interest and feel ambiguity till the problem is not solved so that's why i take work as a challenge and enjoy my work with comfort and hard work rather to speak about my sel More
i can finish it in time without any errors ...i have bid for minimum account ....i need good reviews....i had data structures as my subject.