A double-ended queue or deque (pronounced “deck”) is like a stack or a queue but supports adding and removing items at both ends. A deque stores a collection of items and supports the following API: public class Deque implements Iterable Deque() create an empty deque boolean isEmpty() is the deque empty? int size() number of items in the deque void pushLeft(Item item) add an item to the left end void pushRight(Item item) add an item to the right end Item popLeft() remove an item from the left end Item popRight() remove an item from the right end API for a generic double-ended queue Write a class Deque that uses a doubly-linked list to implement this API and a class ResizingArrayDeque that uses a resizing array
A double-ended queue or deque (pronounced “deck”) is like a stack or a queue but supports adding and removing items at both ends. A deque stores a collection of items and supports the following API: public class Deque implements Iterable Deque() create an empty deque boolean isEmpty() is the deque empty? int size() number of items in the deque void pushLeft(Item item) add an item to the left end void pushRight(Item item) add an item to the right end Item popLeft() remove an item from the left end Item popRight() remove an item from the right end API for a generic double-ended queue Write a class Deque that uses a doubly-linked list to implement this API and a class ResizingArrayDeque that uses a resizing array
Step by step
Solved in 5 steps with 6 images