Given the Node Class, write the code for:
creating an empty list
x = Linkedlist(value)
Given the Node Class, write the code for:
Adding new node to head of linkedlist
def add_head(self, value):
new_node = Node(value)
new_node.set_next(self.head)
self.head = new_nodeGiven the Node Class, write the code for:
Adding new node to tail of linkedlist
def add_tail(self, value):
new_node = Node(value)
current = self.head
while current.get_next() != None:
current = current.get_next()
current.set_next(new_node)Given the Node Class, write the code for:
Removing node from tail of linkedlist
def remove_tail(self, value):
previous = None
current = self.head
while current.get_next() != None:
previous = current
current = current.get_next()
previous.set_next(current.get_next())Given the Node Class, write the code for:
Removing node from head of linkedlist
def remove_head(self):
previous = None
current = self.head
self.head = current.get_next()