Skip to content

Commit 65792ba

Browse files
authored
Merge pull request #49 from ProNinja07/master
Add files via upload
2 parents 4188169 + d567ef8 commit 65792ba

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Data Strucrures/linked list.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)