Question: Why is the highlighted current_node = None? Why is current_node set to None? For example: if we call remove_node(70) 90 -> 5675 -> 70 ->

 Why is the highlighted "current_node = None"? Why is current_node set

Why is the highlighted "current_node = None"? Why is current_node set to None? For example:

if we call remove_node(70)

90 -> 5675 -> 70 -> 5

if current_node = 5675 and next node = 70

current_node.next_node = 5

but wouldn't removing current node remove 5675?

class Node: def __init__(self, value, next_node=None): self.value = value self.next_node = next_node class LinkedList: def __init__(self, head_node=None): self.head_node = head_node def remove_node(self, node_to_remove): current_node = self.head_node if current_node == node_to_remove: self.head_node = current_node.next_node else: while current_node: next_node = current_node.next_node if next_node == node_to_remove: # --> what line of code goes here? current_node None else: current_node = next_node

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!