// Data Structure Invariants: // f index of q w/ front of queue, unless queue empty // r index of q w/ next open slot // f==r means queue is empty Algorithm size() return ( N - f + r ) mod N Algorithm isEmpty() return ( f==r ) Algorithm front() if isEmpty() throw exception else return q(f) Algorithm dequeue() if isEmpty() throw exception else return q(f++ mod N) Algorithm enqueue(o) if isFull() throw exception else q(r) gets o, and r++ mod N Algorithm isFull() return ( size==N-1 )