Inserting/Adding Elements Before The Given Node in The Linked List | Python Program

Pubblicato il: 06 ottobre 2020
sul canale di: Amulya's Academy
60,199
1.1k

In this Python Programming video tutorial you will learn about how to implement Linked List data structure in python 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.

To implement Singly Linked List we are using class concepts here.

Program:
def add_before(self,data,x):
if self.head is None:
print("Linked List is empty!")
return
if self.head.data==x:
new_node = Node(data)
new_node.ref = self.head
self.head = new_node
return
n = self.head
while n.ref is not None:
if n.ref.data==x:
break
n = n.ref
if n.ref is None:
print("Node is not found!")
else:
new_node = Node(data)
new_node.ref = n.ref
n.ref = new_node

#DataStructures #PythonPrograms #LinkedList

For more free tutorials on computer programming
  / amulsacademy  
twitter.com/AmulsAcademy


In questa pagina del sito puoi guardare il video online Inserting/Adding Elements Before The Given Node in The Linked List | Python Program della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Amulya's Academy 06 ottobre 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 60,199 volte e gli è piaciuto 1.1 mille spettatori. Buona visione!