Reading material

Pages 140-145 (Section 4.1.2), pages 152-155 (Section 4.2.2) and pages 100-103 (Section 3.2)

Additional material

Implementation of a stack and queue with an array in pseudocode: PostScript and PDF

ArrayStack
StackFullException
ArrayQueue
QueueFullException

Question

Consider the implementation of a queue by means of a circular array. Assume that the array has 4 cells. The integer variables front and rear are initialized to 0. Complete the following table.
operationfrontrear
enqueue(4)01
enqueue(5)02
dequeue()12
enqueue(2)
dequeue()
enqueue(3)
enqueue(2)
dequeue()
dequeue()