Question: Implement a class that supports the following API, which generalizes both a queue and a stack by supporting removal of the (i) th most recently
Implement a class that supports the following API, which generalizes both a queue and a stack by supporting removal of the \(i\) th most recently inserted item:

First, develop an implementation that uses a resizing array, and then develop one that uses a linked list.
public class GeneralizedQueue GeneralizedQueue () boolean isEmpty () void add (Item item) Item remove (int i) int size() create an empty generalized queue is the generalized queue empty? insert item into the generalized queue remove and return the ith least recently inserted item number of items on the queue API for a generic generalized queue
Step by Step Solution
3.38 Rating (157 Votes )
There are 3 Steps involved in it
Lets write a class that implements the API described in your question We will create two implementations for the GeneralizedQueue class one using a re... View full answer
Get step-by-step solutions from verified subject matter experts
