Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the following information write fill in the implementation need in order t

ID: 3731766 • Letter: U

Question

Using the following information write fill in the implementation need in order to remove a node from the front, back, and middle of the doubly linked list. Using python

class DoubleLinked_List:

class __Node:

def __init__(self, val):
self.val = val
self.next = None
self.prev = None
return


def __init__(self):
self.__header = self.__Node(None)
self.__trailer = self.__Node(None)
self.__header.next = self.__trailer
self.__trailer.prev = self.__header
self.__size = 0


def __len__(self):
return self.__size

def remove(self, index):

#implementation goes here.

Explanation / Answer

#code to remove element at index in doubly linked list def remove(self, index): if index > self.__size or index < 0 or index == self.__size: raise IndexError current = self.__header.next element_to_return = current if index == 0: self.__header.next = self.__header.next.next else: for i in range(0, index): current = current.next element_to_return = current current.next = current.next.next self.__size -= 1 return element_to_return.val