May 2017
Intermediate to advanced
310 pages
8h 5m
English
The queue class is very similar to that of the doubly linked list class:
class Queue: def __init__(self): self.head = None self.tail = None self.count = 0
self.head and self.tail pointers are set to None upon creation of an instance of the queue class. To keep a count of the number of nodes in Queue, the count instance variable is maintained here too and set to 0.