Posted on 25th April 2024
A linked list is a series of data elements, that are joined mutually through links. Every data element includes a connection over another data element within the form of any pointer. Python does not own linked lists within its standard library. We achieve the idea of linked lists utilising the idea of nodes here is the example to create a linked list
class Node:
def __init__(self, dataval=None):
self.dataval = dataval
self.nextval = None
class SLinkedList:
def __init__(self):
self.headval = None
list1 = SLinkedList()
list1.headval = Node("One")
a2 = Node("Two")
a3 = Node("Three")
list1.headval.nextval = a2
a2.nextval = a3
STILL GOT QUERIES?