Question: In C++, Implement a MyQueue class which implements a queue using two stacks . private int maxCapacity = 4; private Stack stack1; private Stack stack2;
In C++,
Implement a MyQueue class which implements a queue using two stacks.
private int maxCapacity = 4;
private Stack stack1;
private Stack stack2;
Note:
You can use library Stack but you are not allowed to use library Queue and any of its methods
Your Queue should not accept null or empty String or space as an input
You need to implement the following methods using two stacks (stack1 & stack2) and also you can add more methods as well:
public int size()
public void insert(String value)
public String remove()
private void shiftStacks()
public boolean isEmpty()
public boolean isFull()
Test case1: Testing empty queue
Input1:
1
Output1:
[0:Empty:]
Test case2: Testing insert method
Input2:
2
4
a
b
c
d
Output2:
[4:Full:a, b, c, d]
Test case3: Testing remove method
Input3:
3
4
a
b
c
d
Output3:
[3:b, c, d]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
