Complete the code to add a new node at the front of the dequeue.
def add_front(self, data): new_node = Node(data) if self.front is None: self.front = self.rear = new_node else: new_node.next = [1] self.front.prev = new_node self.front = new_node
The new node's next should point to the current front node.
Complete the code to remove a node from the rear of the dequeue.
def remove_rear(self): if self.rear is None: return None data = self.rear.data self.rear = self.rear.prev if self.rear is not None: self.rear.next = [1] else: self.front = None return data
After removing the rear node, if rear exists, its next should be None.
Fix the error in the code to add a node at the rear of the dequeue.
def add_rear(self, data): new_node = Node(data) if self.rear is None: self.front = self.rear = new_node else: self.rear.next = new_node new_node.prev = [1] self.rear = new_node
The new node's prev should point to the current rear before updating rear.
Fill both blanks to correctly remove a node from the front of the dequeue.
def remove_front(self): if self.front is None: return None data = self.front.data self.front = self.front.[1] if self.front is not None: self.front.[2] = None else: self.rear = None return data
To remove the front node, move front to front.next and set new front's prev to None.
Fill all three blanks to create a dictionary comprehension that maps each node's data to its position if data is positive.
def map_positive_nodes(self): result = {node.data[1]: idx for idx, node in enumerate(self.iterate()) if node.data [2] 0 and node.data is not [3] None} return result
The comprehension maps node.data plus idx as key, filters nodes with data > 0, and excludes None data.