Question: Refresher: We have seen in class that a queue is an abstract data type, also called a First-In-First-Out (FIFO) data structure because the first element



Refresher: We have seen in class that a queue is an abstract data type, also called a First-In-First-Out (FIFO) data structure because the first element added/enqueued to the queue is always the first one to be removed/dequeued. A stack is an abstract data type, also called a Last-In-First-Out (LIFO) data structure because the first element added/pushed to the stack is always the last one to be removed/poped. Stack: Queue: Last in, frst out First in, first out Requirements: Write a new class called stackBasedQueue that implements following queue operations using only 2 stacks: enqueue(newltem)- Add an integer input to the back of queue. dequeue() Remove the element from the front of the queue. peek)- Get the front element. isEmpty) Return whether the queue is empty or not. stackBasedQueuel) Constructor that initialize the stacks to create a new queue object .--Class Template--- import java.util.stack; public class stackBasedQueue Stack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
