Using the head pointer, we will be able to traverse the whole
list, even perform all kinds of list manipulations while we are at
it.
For this, we create a LinkedList class with a single head
pointer:
#A single node of a singly linked list class Node:
#constructor:
def__init__(self, data=None,next=None):
self.data= data
self.next=next
#A Linked List class with a single head class LinkedList:
def__init_(self):
self.head =None
#Linked List with a single node
LL=LinkedList ()
LL.head =Node (3)
print (LL.head.data)
3) Your task is to continue the codes given above by adding the
insertion and print methods for the LinkedList implementation. Use
these methods to add the number values given above and show the
output.
Using the head pointer, we will be able to traverse the whole list, even perform all kinds of list manipulations while w
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Using the head pointer, we will be able to traverse the whole list, even perform all kinds of list manipulations while w
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!