''' 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 all nodes 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 P4 (doubly linked list removal) ''' class DLinkedList: """ A user defined doubly linked list""" def __init__(self): self.head = None self.tail = None def __str__(self): """ String function """ s = '[' h = self.head while h != None: s += str(h.data) h = h.next if h != None: s += ', ' s += ']' return s def __len__(self) """count length (the len() function recursively""" pass def insert(self, node): """ Insert a value 'data'""" if self.head == None: # empty list self.head = node self.tail = node else: # insert after tail self.tail.next = node node.prev = self.tail self.tail = node class DListNode: """ The node class for list notes""" def __init__(self, data): self.data = data self.next = None self.prev = None