Consider the following classes Node and LinkedList. Complete the method delete_all_occurrences that removes all of the nodes whose value attribute equals the value parameter. There are no assumptions about the number or positions of such nodes in the linked list. Make sure to update all attributes of the LinkedList object appropriately.
class Node:
def __init__(self, value):
self.value = value
self.next = None
class LinkedList:
def __init__(self):
self.front = None
self.back = None
self.size = 0
def append(self, value):
if self.size == 0:
self.front = Node(value)
self.back = self.front
else:
self.back.next = Node(value)
self.back = self.back.next
self.size = self.size + 1
def delete_all_occurrences(self, value):
# To be implemented