Skip to content

Commit 1891e85

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4f907cc commit 1891e85

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

data_structures/linked_list/add_node.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class node: #define a class named node having data and ref as attributes
22
def __init__(self,data):
3-
self.data=data
4-
self.ref= None
3+
self.data=data
4+
self.ref= None
55
class LinkedList:
66
def __init__(self): #define head of the linked list i.e initiate the linked list
77
self.head=None
@@ -13,10 +13,10 @@ def print_LL(self): # to print the linked list
1313
while n is n ot None:
1414
print(n.data)
1515
n=n.ref
16-
def add_begin(self,data): #to add a node in the beginning
16+
def add_begin(self,data): #to add a node in the beginning
1717
new_node= node(data) #define data of the new node
1818
new_node.ref= self.head #make the ref or adress of node to the head node
19-
self.head = new_node
19+
self.head = new_node
2020
def add_end(self,data):
2121
new_node= node(data)
2222
if self.head is None:
@@ -34,11 +34,11 @@ def add_after(self,data,x):
3434
n=n.ref
3535
new_node=node(data)
3636
new_node.ref= n.ref
37-
n.ref= new_node
37+
n.ref= new_node
3838
linked_list= LinkedList() # main driver function here we define the linked list
3939
linked_list.add_begin(11) #added 11 to the beginning of out linked list
4040
linked_list.add_end(100)
4141
linked_list.add_begin(22)
4242
linked_list.add_after(30,11)
4343
linked_list.print_LL()
44-
#https://youtu.be/xRTdfZsAz6Y?si=EMrqVJpXjDDz1kEF
44+
#https://youtu.be/xRTdfZsAz6Y?si=EMrqVJpXjDDz1kEF

0 commit comments

Comments
 (0)