using an array circularly in developing more robust queue implementationwe allow the front of the queue to drift rightwardand we allow the contents of the queue to "wrap aroundthe end of an underlying array we assume that our underlying array has fixed length that is greater that the actual number of elements in the queue new elements are enqueued toward the "endof the current queueprogressing from the front to index and continuing at index then figure illustrates such queue with first element and last element - figure modeling queue with circular array that wraps around the end implementing this circular view is not difficult when we dequeue an element and want to "advancethe front indexwe use the arithmetic ( recall that the operator in python denotes the modulo operatorwhich is computed by taking the remainder after an integral division for example divided by has quotient of with remainder that is so in python / evaluates to the quotient while evaluates to the remainder the modulo operator is ideal for treating an array circularly as concrete exampleif we have list of length and front index we can advance the front by formally computing ( + which is simply as divided by is with remainder of similarlyadvancing index results in index but when we advance from index (the last one in the array)we compute ( + which evaluates to index (as divided by has remainder of zeroa python queue implementation complete implementation of queue adt using python list in circular fashion is presented in code fragments and internallythe queue class maintains the following three instance variablesdatais reference to list instance with fixed capacity sizeis an integer representing the current number of elements stored in the queue (as opposed to the length of the data listfrontis an integer that represents the index within data of the first element of the queue (assuming the queue is not emptywe initially reserve list of moderate size for storing dataalthough the queue formally has size zero as technicalitywe initialize the front index to zero when front or dequeue are called with no elements in the queuewe raise an instance of the empty exceptiondefined in code fragment for our stack