As discussed in Chapter 8, the JCF provides an interface for a generic double-ended queue which supports insertion and deletion of items from both the front and back of the data structure. Here is a simplified version of a generic deque interface:
public interface Deque
boolean isEmpty();
// Return true if the deque is empty, false otherwise.
boolean addFirst(E item);
// Insert the item at the front of the deque. Returns false
// if the item cannot be added to the deque, true otherwise.
boolean addLast(E item);
// Insert the item at the back of the deque. Returns false if
// the item cannot be added to the deque, true otherwise.
boolean contains(Object o);
// Returns true if this deque contains the specified element.
E removeFirst();
// Delete and return the first item in the deque if the deque
// is not empty, otherwise return null (the deque was empty).
E removeLast();
// Delete and return the last item in the deque if the deque
// is not empty, otherwise return null (the deque was empty).
E peekFirst();
// Return the first item in the deque if the deque is
// not empty, leaving the deque unchanged. Otherwise return
// null (the deque was empty).
E peekLast();
// Return the last item in the deque if the deque is
// not empty, leaving the deque unchanged. Otherwise return
// null (the deque was empty).
} // end Deque
a. Create a reference-based implementation of this generic Deque interface.
b. Create an array-based implementation of this generic Deque interface using ArrayList.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.