Question: ITS PYTHON CODE Our goal for this worksheet is to extend our LinkedList class by implementing one of the standard mutating List ADT methods: inserting


IT"S PYTHON CODE
Our goal for this worksheet is to extend our LinkedList class by implementing one of the standard mutating List ADT methods: inserting into a list by index. Here's the docstring of such a method: def insert(self, index: int, item: Any) None: "n"Insert the given item at the given index in this list. Raise IndexError if index > len(self) or index len( self )==4, index ==2, which existing node was actually mutated? Write down the index of this node in the list; hint, it's not the one at index 2 ! 3. Finally, using these ideas, implement the insert method in the space below. Note that you should have two cases: one for when you need to mutate self._first, and one where you don't. Also, you'll want to use the same approach as LinkedList._-getitem_- and keep two parallel variables curr and
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
