As discussed in this chapter, the JCF provides an interface for a double ended queue that supports insertion and deletion of items from both the front and back of the data structure. Here is a simplified version of a deque interface:
public interface Deque {
public boolean isErapty();
// Return true if the deque is empty, false otherwise.
public boolean addFirst(Object item);
// Insert the item at the front of the deque. Returns false
// if the item cannot be added to the deque, true otherwise.
public boolean addLast(Object item);
// Insert the item at the back of the deque. Returns false if
// the item cannot be added to the deque, true otherwise.
public Object removeFirst();
// Delete and return the first item in the deque if the deque
// is not empty, otherwise return null (the deque was empty).
public Object removeLast();
// Delete and return the last item in the deque if the deque
// is not empty, otherwise return null (the deque was empty).
public Object 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).
public Object 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 the Deque interface.
b. Create an array-based implementation of the Deque interface.
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.