Delete a node in a Doubly Linked List

Sairam Penjarla
Dec 27, 2020
def delete(self,element):
temp = self.head
if temp == None:
return
if temp.data == element:
temp.next.prev = None
self.head = temp.next
return
while(temp):

if temp.data == element:
if temp.next == None:
temp.prev.next = None
temp.prev = None
return
temp.prev.next = temp.next
temp.next.prev = temp.prev
return
temp = temp.next

--

--

Sairam Penjarla

Looking for my next opportunity to make change in a BIG way