Linked List
- Create a simple linked list of strings
"mon"->"tue"->"wed"
- Traverse a linked list and print elements of the list
- Insert
"sun"
at the begining
- Insert
"fri"
at the end
- Add element
"thur"
in b/w the nodes
- [Now replace the element
"thur"
by "thu"
]
- [Count the number of elements in the linked list]
- [Search an element in a linked list]
- [Link the start-end nodes, form a circular linked list]
- [Search an element in the circular liked list]
- [Insert an element at random position and count the list]
linkedList()
class Node:
def __init__(self, val=None):
self.val = val
self.next = None
class LinkedList:
def __init__(self):
self.head = None
llist = LinkedList()
llist.head = Node("mon")
llist.head.next = e2
e3 = Node("wed")
e2 = Node("tue")
e2.next = e3
llist.printList()
traverseLinkedList 
class LinkedList:
def __init__(self):
self.head = None
def printList(self):
temp = self.head
while(temp):
print(temp.val)
temp = temp.next
llist.printList()
atBegining 
def atBegin(self, data_i):
e0 = Node(data_i)
"Let's update the list"
temp = self.head
self.head = e0
e0.next = temp
llist.atBegin("sun")
atEnd

def atEnd(self, data):
en = Node(data)
temp = self.head
while(temp.next):
temp = temp.next
temp.next = en
def atEnd(self, data):
en = Node(data)
if self.head is None:
self.head = en
return
temp = self.head
while(temp.next):
temp = temp.next
temp.next = en
llist.atEnd("fri")
Insertion in b/w the nodes 
def inBetween(self, inode, data):
ei = Node(data)
ei.next = inode.next
inode.next = ei
llist.inBetween(e3, "thur")