Using the head pointer, we will be able to traverse the whole list, even perform all kinds of list manipulations while w

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
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

Post by answerhappygod »

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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply