
Linked List Creation--
class Node: # Node Creation def __init__(self, data): self.data=data self.ref=None class LinkedList: # Connecting the nodes def __int__(self): self.head=None def print_ll(self): # Printing of the created linhed list if self.head is None: print("Linked list is empty") return n=self.head while n: print(n.data) n=n.refnode1 =Node(10) # Given the vazlue in the 1st nodenode2=Node(2) # Giving the value in the second nodeq1=LinkedList() # Calling the Linkeglist functionq1.head=node1 # pointing of q1 as a head nodenode1.ref=node2 # storing the addresss of the 2nd node into first nodeq1.print_ll() # printing of q1
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse