1. Use an instance of the standard class Vector to implement the queue. How does this implementation compare with the array-based approach given in this chapter?
2. Use a circular array, as described in Segments 8.8 and 8.9, to implement the queue. Count entries to ascertain whether the queue is empty or full.
3. The implementation of the ADT queue that was introduced in Segment 8.10 uses a circular array with one unused element. Revise that implementation so that the unused element is always before the front of the queue, with frontIndex as the index of this unused element. Let backIndex be the index of the entry at the back of the queue. Initially, both frontIndex and backIndex are set to the maximum size of the queue (the array will be 1 larger than this number). You can distinguish an empty queue from a full queue by examining these indices. What tests should you perform to do so?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here