Question: Develop a Python Solution to the following problems. 1. Motivating observations. a. The remove method causes an error when attempting to remove an item that

 Develop a Python Solution to the following problems. 1. Motivating observations.
a. The remove method causes an error when attempting to remove an
item that is not in the Unorderedlist. b. The append, insert, index,
and pop methods are not implemented in the UnorderedList class. 2. Modify
the remove method in the Unorderedlist class as follows. a. When the

Develop a Python Solution to the following problems. 1. Motivating observations. a. The remove method causes an error when attempting to remove an item that is not in the Unorderedlist. b. The append, insert, index, and pop methods are not implemented in the UnorderedList class. 2. Modify the remove method in the Unorderedlist class as follows. a. When the item is found in the Unorderedlist, remove the item from the linked list and return True. b. When the item is NOT found in the Unorderedlist, 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. 1. When pos is not valid, return false. Note: the pos value is invalid if it is less than zero or greater than size(): il. 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. a. 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. 5. What files should you submit? a. Submit one Python source code file which contains your solution to steps 2, 3, and 4. 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 roa Mode import Mode This class implements the folloding methods: add(iten) search(item remove(item isEmpty() size() The other methods in this class must be implemented. class Unordered List: der init__(self): sel.head - None Purpose: add item to front of List Assumptions: none Inputs: selt: the Unorderedlist object item: object to be added to list #Outputs: updates self head def add(self, iten): temp. Node(iten) temp.setNext(selt head) selhead - temp Purpose: search for iten in list Assumptions: none Inputs: set the Unorderedlist object Item: object being searched for Outputs: returns True when item found; otherwise returns False det search(setite) current sel head found False while current long and not found: current getData() sites found True current current get ext() return found Purpose remove item from list Assumptions Item 1 Found in the list Input sell the Unorderedlist object item object to be removed =Outputs updates self head when necessary de remove item current head VSNethe sound = False le not found 1+ current ge-Data found ent Entent Current settes SEE MORE te huad - current est frode import de this clase plate the following theder ada(iten) search(at) remove(item) . laptyt ) stre the other methods in the class simplemented. class orderedlist definit(wif): solr.head - None Purpose: Add item to front of list Assumptions: none Inputs: self: the unorderedlist object test object to be added to list outputst updates serhead der addott, it) tenp - Node(ite) temp.setNext(str.head) self.head-temp Purpose: search for item in list ASSUNOT ons none Inputs: self: the orderedlist object test object being searched for Outputs return True when its found; otherwise returns False def search(self, ite) current self head found - False while Current None and not found if current.getData) - test found - True current -current petrext() return found Purpose: Porove item from list Auntions: item is found in the list Inputot self the orderedlist object ste object to be removed Outputs: updates belhead whecetary der renoverself. Item Current er.head previous - None Pound Fat while not found af current.getoata ste fond - True ser Brev - Current current current text ir previous Delfines - current sett else: previous.setNext(current.getNext() def 1sEmpty(self): return self.head - None #Purpose: determine size of List #Assumptions: none #Inputs: self: the UnorderedList object #outputs: returns integer representing size of list def size(self): current = self.head count = while current = None: count = count + 1 current -current.getNext() return count def _str__(self): result = current = self.head white current = None: if Len(result) > 0: result = result + result - result - str(current.getData()) current = current.getNext() return "unorderedlist - result

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!