Question: Python code check. I wrote this code for an assignment but I'm not good at writing test cases. Can someone tell me if the code

Python code check. I wrote this code for an assignment but I'm not good at writing test cases. Can someone tell me if the code will do what it's supposed to?

Prompt: Items are added to the back of the queue using the next free entry in an array. Items are removed from the front of the queue. The indices front and back are incremented as items are added and deleted from the queue, and the indices wrap around when they reach the end of the array.

All methods must have O(1) performance You may NOT use any of the following Python List operations:  o append()  o insert()  o extend()  o remove()  o pop()  o + (concatenations)  ________________________________________________________________________________________________________________________ class Queue: '''Implements an array-based, efficient first-in first-out Abstract Data Type  using a Python array (faked using a List)'''   def __init__(self, capacity): '''Creates an empty Queue with a capacity'''  self.queue = [] * capacity self.capacity = capacity self.numitems = self.front = self.back = 0 def is_empty(self): '''Returns True if the Queue is empty, and False otherwise'''  return self.numitems == 0 def is_full(self): '''Returns True if the Queue is full, and False otherwise'''  return self.numitems == self.capacity def enqueue(self, item): '''If Queue is not full, enqueues (adds) item to Queue  If Queue is full when enqueue is attempted, raises IndexError'''  if Queue.is_full(self): raise IndexError('Stack is full') else: self.queue[self.back] = item self.numitems += 1 self.back += 1 Queue.indexcheck(self) def dequeue(self): '''If Queue is not empty, dequeues (removes) item from Queue and returns item.  If Queue is empty when dequeue is attempted, raises IndexError'''  if Queue.is_empty(self): raise IndexError('Stack is empty') else: item = self.queue[self.front] self.queue[self.front] = None self.numitems -= 1 self.front += 1 Queue.indexcheck(self) return item def size(self): '''Returns the number of elements currently in the Queue, not the capacity'''  return self.numitems # functions added by student: def indexcheck(self): '''If the front or back reach the end of the stack, returns them to the  beginning in order to simulate a "wrap around" effect.'''  if self.front == self.capacity: self.front = 0 if self.back == self.capacity: self.back = 0 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!