def enqueue(selfe)"""add an element to the back of queue ""if self size =len(self data)double the array size self resize( len(self data)avail (self front self sizelen(self dataself data[availe self size + we assume cap >len(selfdef resize(selfcap)"""resize to new list of capacity >len(self""keep track of existing list old self data allocate list with new capacity self data [nonecap walk self front only consider existing elements for in range(self size)intentionally shift indices self data[kold[walkwalk ( walklen(olduse old size as modulus front has been realigned self front code fragment array-based implementation of queue (continued from code fragment the implementation of len and is empty are trivialgiven knowledge of the size the implementation of the front method is also simpleas the front index tells us precisely where the desired element is located within the data listassuming that list is not empty adding and removing elements the goal of the enqueue method is to add new element to the back of the queue we need to determine the proper index at which to place the new element although we do not explicitly maintain an instance variable for the back of the queuewe compute the location of the next opening based on the formulaavail (self front self sizelen(self datanote that we are using the size of the queue as it exists prior to the addition of the new element for exampleconsider queue with capacity current size and first element at index the three elements of such queue are stored at indices and the new element should be placed at index (front size in case with wrap-aroundthe use of the modular arithmetic achieves the desired circular semantics for exampleif our hypothetical queue had elements with the first at index our computation of ( + evaluates to which is perfect since the three existing elements occupy indices and