Question: In this problem, you will write some code for operations on a singly linked list where values in each Node are integers only. Assume
In this problem, you will write some code for operations on a singly linked list where values in each Node are integers only. Assume you already have the following code. Assume the method bodies, even though not shown, are correct and implement the operations as we defined them in lecture. class Node: definit (self, value): value self.value self.next None def_str_(self): ***String representation of Node object*** repr__str_ class Linkedlist: definit__(self): self.head-None self. tail-None def_str_(self): repr_=_str_ def isEmpty(self): deflen_(self): *** String representation of LinkedList object""" "*" Returns True when list is empty, False otherwise""" ***Returns the number of nodes in the list *** Write the implementation for the special method_contains__(self, value) in the LinkedList class that returns True when the list contains a Node with that value, False otherwise, but when a Node is found by this method, it moves the Node to the front of the list without changing the relative order of the other nodes. You can assume the values in the list are unique. Be sure to handle the cases of moving the last node! To receive any credit for this question, you are NOT allowed to create new nodes, swap data between nodes or copy elements of the linked list into a Python list (or any other data structure) >>> 1st Head: Node(-5) Tail: Node (9) List: -5 Example: >>> 1st Head: Node(7) Tail: Node (9) List: 7-1-3-4-5-8->9 >>> -5 in 1st True >>> 1st Head: Node(-5) Tail: Node (9) List: -57-13 4 8 9 >>> 33 in 1st False 7 1 3 4 8 9
Step by Step Solution
There are 3 Steps involved in it
There is no image currently att... View full answer
Get step-by-step solutions from verified subject matter experts
