Question: Please use python Modify here is the node if you need Develop a Python solution to the following problems. a. 1. Motivating observations. The remove

Please use python

Please use python Modify here is the node if you need Develop

Modify

a Python solution to the following problems. a. 1. Motivating observations. The

here is the node if you need

remove method causes an error when attempting to remove an item that

Develop a Python solution to the following problems. a. 1. Motivating observations. The remove method causes an error when attempting to remove an item that is not in the Unordered List. b. The append, insert, index, and pop methods are not implemented in the Unordered List class. a. 2. Modify the remove method in the Unordered List class as follows. When the item is found in the Unordered List, remove the item from the linked list and return True. b. When the item is NOT found in the Unordered List, return false. 3. Modify the Unordered List class as follows. a. Implement the index(self,item) method. i. When the item is found, this method should return the position of the item in the Unordered List. Note: the item at the head of the list is at position zero, the next item is at position one, and so on. ii. When the item is NOT found, this method should return -1. b. Implement the insert(pos,item) method. i. When pos is not valid, return False. Note: the pos value is invalid if it is less than zero or greater than size(). ii. Otherwise, insert the item at the pos position so the item just inserted is at this index position after the insert has completed. Note: the item at the head of the list is at position zero, the next item is at position one, and so on. 4. In your source code file, add test code to test your modifications to the Unordered List class. Think about the test cases you need to implement for each modification you made. b. Be sure to apply separation of concerns and design for reuse when developing your test code. a. from Node import Node class UnorderedList: def __init__(self): self.head = None def isEmpty(self): return self.head == None def add(self, item): temp = Node (item) temp.setNext(self.head) self.head = temp def size(self): current = self.head count = 0 while current != None: count = count + 1 current = current.getNext() return count def search(self, item): current = self.head found = False while current != None and not found: if current.getData() == item: found = True else: current = current.getNext() return found def remove(self, item): current = self.head previous one found = False while not found: if current.getData() item: found = True else: previous = current current = current.getNext() if previous == None: self.head = current.getNext(). else: previous.setNext(current.getNext()) def str-- (self): result = "" current = self.head while current != None: if len(result) > 0: result = result + "" result = result + str(current.getData()) current = current.getNext(). return "UnorderedList:" + result class Node: def __init__(self, initdata): self.data = initdata self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self, newdata): self.data = newdata def setNext(self, newnext): self.next = newnext

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!