We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4188169 + d567ef8 commit 65792baCopy full SHA for 65792ba
Data Strucrures/linked list.py
@@ -0,0 +1,32 @@
1
+# A simple Python program to introduce a linked list
2
+
3
+# Node class
4
+class Node:
5
6
+ # Function to initialise the node object
7
+ def __init__(self, data):
8
+ self.data = data # Assign data
9
+ self.next = None # Initialize next as null
10
11
12
+# Linked List class contains a Node object
13
+class LinkedList:
14
15
+ # Function to initialize head
16
+ def __init__(self):
17
+ self.head = None
18
19
20
+# Code execution starts here
21
+if __name__=='__main__':
22
23
+ # Start with the empty list
24
+ llist = LinkedList()
25
26
+ llist.head = Node(1)
27
+ second = Node(2)
28
+ third = Node(3)
29
30
+ llist.head.next = second; # Link first node with second
31
32
+ second.next = third; # Link second node with the third node
0 commit comments