Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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_nodeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started