Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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