In this Python Programming video tutorial you will learn about doubly Linked List data structure and also you will write the program for insertion operation in detail.
Data structure is a way of storing and organising the data so that it can be accessed effectively.
Linked List is a linear data structure made up of chain of nodes in which each node contains a data field and link or reference.
There are different types of linked list. Here we will discuss about 3 common types of linked list. doubly linked list is one of them. Here we will discuss doubly linked list operations and definitions in detail.
Here we will write three methods for insertion operation.
def insert_empty(self,data):
if self.head is None:
new_node = Node(data)
self.head = new_node
else:
print("Linked List is not empty!")
def add_begin(self,data):
new_node = Node(data)
if self.head is None:
self.head = new_node
else:
new_node.nref = self.head
self.head.pref = new_node
self.head = new_node
def add_end(self,data):
new_node = Node(data)
if self.head is None:
self.head = new_node
else:
n = self.head
while n.nref is not None:
n = n.nref
n.nref = new_node
new_node.pref = n
#DataStructures #PythonPrograms #LinkedList
For more free tutorials on computer programming
/ amulsacademy
twitter.com/AmulsAcademy