''' CSCI 204.01 Exam 1 review exercise Divide the students into groups and each group solves one proble, then exchange their ideas or solution. 1. Write a Python function that can remove a node with specific data value in a doubly linked list. 2. Write a Python function that can count the number of nodes in a circular linked list with a specific data value. 3. Write an operator overloading function __sub__ that removes a node with specified value in a singly linked list. 4. Write a recursive function to compute the length of a singly linked list. 5. Write a child class with a constructor, string function, length function that inherits information from a parent class. ''' ''' This is the start file for P1 and P4 (singly linked list ''' class UserList: def __init__(self): self.head = None self.tail = None def insert_after(self, data): """ Insert a node with data at the end of the list """ node = ListNode(data) if self.is_empty(): # the node will be the first one in list self.head = node self.tail = node else: # insert after the current tail self.tail.next = node self.tail = node def is_empty(self): """ Return True if the list is empty, False otherwise. """ return self.head == None def __sub__(self, rhs_node): """Overload the operator '-' so that l = l - node is valid""" pass def remove_all(self, value): """Remove all nodes with given value in the list""" pass class ListNode: """ The node class for list notes""" def __init__(self, data): self.data = data self.next = None