Doubly Linked List
Doubly linked list is a data structure that consists of a group of nodes where each node contains a piece of data and two pointers, one to the previous node and one to the next node in the list.
Constructor
class Node:
def __init__(self, value):
self.value = value
self.next = None
self.prev = None
class DoublyLinkedList:
def __init__(self, value):
new_node = Node(value)
self.head = new_node
self.tail = new_node
self.length = 1
def print_list(self):
temp = self.head
while temp is not None:
print(temp.value)
temp = temp.nextAppend
Pop
Prepend
Pop first
Get
Set
Insert
Remove
Last updated