defprintCQueue(self): if(self.head == -1): print("No element in the circular queue")
elif (self.tail >= self.head): for i in range(self.head, self.tail + 1): print(self.queue[i], end=" ") print() else: for i in range(self.head, self.k): print(self.queue[i], end=" ") for i in range(0, self.tail + 1): print(self.queue[i], end=" ") print()
# Your MyCircularQueue object will be instantiated and called as such: obj = MyCircularQueue(5) obj.enqueue(1) obj.enqueue(2) obj.enqueue(3) obj.enqueue(4) obj.enqueue(5) print("Initial queue") obj.printCQueue()
obj.dequeue() print("After removing an element from the queue") obj.printCQueue()