Question: class Node: def __init__(self, data = None, nextw= None): self.data = data self.next = next class LinkedList(: def __init__(self): pass def push_front(self, data): pass def


class Node: def __init__(self, data = None, nextw= None): self.data = data self.next = next class LinkedList(: def __init__(self): pass def push_front(self, data): pass def popafront(self): return None def push_back(self, data): pass def pop back(self): return None def getasize (self): return 0 def _str__(self): return . o o o 20% Implement the singly-linked list class LinkedList including the following operations: push_back Takes a parameter and adds its value to the back of the list push_front Takes a parameter and adds its value to the front of the list pop_front Removes the item from the front of the list and returns its value If the list is empty, return None pop_back Removes the item from the back of the list and returns its value If the list is empty, return None get_size Returns the number of items currently in the list str Returns a string with all the items in the list, separated by a single space For full marks, implement all these operations (apart from str and pop_back) with time complexity O(1) . o o o
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
