Problem

As discussed in this chapter, the JCF provides an interface for a double ended queue that...

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.

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 8
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT