Circular queue implemented in array. (Corrected error in print() ) Always keep one node empty. head points to first element in queue. tail points to location where next element is to be inserted NOTE ALL ADDITION (including ++) is % size /* initialize queue pointers */ head = tail = 0; /* test for full */ return head == tail + 1; /* test for empty */ return head == tail; /* insert x at tail */ if ( !full) q[tail++] = x; /* delete from head */ if ( !empty) return q[head++]; /* print from head to tail */ /* note, this is not really a queue operation, but is handy for debugging */ if (!empty) for (n = head; n != tail-1; n ++) // n = head; n != tail - 1; n++ print q[n];