Question: Mod 4 Homework - Enhanced DoublyLinkedList Hello, can you please show me how to implement 'contains' using the #TODO starter code (def __contains__)? 2) Implement

Mod 4 Homework - Enhanced DoublyLinkedList

Mod 4 Homework - Enhanced DoublyLinkedList Hello, can you please show mehow to implement 'contains' using the #TODO starter code (def __contains__)? 2)

Hello, can you please show me how to implement 'contains' using the #TODO starter code (def __contains__)?

2) Implement _._contains __(item) nodes is a private attribute, and thus should not be called explicilty in your tests. Instead, use nodes to add a O(1).. contains__ 0 method to your DLL, and test __contains__ O : > di1 - DoublyLinkedi 1 st (range (5)) ) 3 in dil #O(1), even though 3 is in the middle. True 3>s 5 in dill \# Note the use of 'in' to call the dinder method \( \ldots_{\text {contains__ } 0} \) False Write a unittest that verifies contains works as expected as you add and remove nodes. 3) Implement neighbors (item) Add a method neighbors (item) to your DoublyLinkedi,iat class that returns the items immediately before and after the node with item: s> di1 = DoublyLinkedList ( range (5)) >> d11. neighbors (3) (2,4) >> di1. neighbora (0) \#Edge case - head (kone, 1) 33> d11. noighbore(4) \# Edge case - tatb (3, None) - Strould be O(1) - When called on the item stored in the head/tail, return None us the previousext item, as shown above - Raise a RuntimeError if someone searches for an item not in the DIL. Include unitleats for the above behavior (exeept the running time). 4) Implement remove_node (item) File Edit Selection View Go Run Terminal Help Restricted Mode is intended for safe code browsing. Trust this window to enable all features. Manage TestDoublyLinkedList.py 1 DoublylinkedList.py X def duplicates1(L): Untitle C: > Users > iamla > AppData > Local > Temp > Temp1_hw4_starter (1).zip > Doublylinked oo \# was that tne tast noder 87 if len(self)=0: self._head = None 88 else: self._tail._next = None 9091 return item 92 TODO: Add a docstring and implement 94 |ef contains_(self, item): * TODO: Add a docstring and implement def neighbors(self, item): raise Notimplementederror \# TODO: Add a docstring and implement def renove_node(self, item): rase MotImplementedError

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!