| 1. |
Adapted from Sahni, Chapter 10, Question 7 (a)-(c)
Write a cyclic block implementation of the double-ended queue (deque) ADT introduced in Practice Sheet 4.
Your implementation should contain the following methods:
DequeCharCyclic(s): create an empty deque of size s.
isEmpty(): return true iff the deque is empty, false otherwise.
isFull(): return true iff the deque is full, false otherwise.
pushLeft(c): add character c as the left-most character in the deque, or throw an Overflow exception if the deque is full.
pushRight(c): add character c as the right-most character in the deque, or throw an Overflow exception if the deque is full.
peekLeft(): return the left-most character in the deque, or throw an Underflow exception if the deque is empty.
peekRight(): return the right-most character in the deque, or throw an Underflow exception if the deque is empty.
popLeft(): remove and return the left-most character in the deque, or throw an Underflow exception if the deque is empty.
popRight(): remove and return the right-most character in the deque, or throw an Underflow exception if the deque is empty.
|