Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Data Strucrures/linked list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# A simple Python program to introduce a linked list

# Node class
class Node:

# Function to initialise the node object
def __init__(self, data):
self.data = data # Assign data
self.next = None # Initialize next as null


# Linked List class contains a Node object
class LinkedList:

# Function to initialize head
def __init__(self):
self.head = None


# Code execution starts here
if __name__=='__main__':

# Start with the empty list
llist = LinkedList()

llist.head = Node(1)
second = Node(2)
third = Node(3)

llist.head.next = second; # Link first node with second

second.next = third; # Link second node with the third node