Complete the code to create a node with given data.
class Node: def __init__(self, data): self.data = [1] self.next = None
The node stores the given data in self.data. So, we assign the parameter data to self.data.
Complete the enqueue method to add a new node at the end of the queue.
def enqueue(self, data): new_node = Node(data) if self.rear is None: self.front = self.rear = new_node else: self.rear.next = [1] self.rear = new_node
To add a new node at the end, set the current rear's next pointer to the new node.
Fix the error in the dequeue method to correctly remove the front node.
def dequeue(self): if self.front is None: return None temp = self.front self.front = self.front.[1] if self.front is None: self.rear = None return temp.data
To remove the front node, update self.front to point to the next node after the current front.
Fill both blanks to check if the queue is empty.
def is_empty(self): return self.[1] is [2]
The queue is empty if the front pointer is None.
Fill all three blanks to implement a method that prints all elements in the queue.
def display(self): current = self.[1] while current is not [2]: print(current.[3], end=' -> ') current = current.next print('None')
Start from the front node, loop until current is None, and print each node's data.
