a) Write a function to get the value of the Nth node in a Linked List. [Note: The first (N=1) item in the list means the

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

a) Write a function to get the value of the Nth node in a Linked List. [Note: The first (N=1) item in the list means the

Post by answerhappygod »

a) Write a function to get the value of the
Nth node in a Linked List. [Note: The first (N=1)
item in the list means the item at index 0.] It takes two
parameters: the list or its head, and N. Return False if the list
has fewer than N elements. The Linked List structure supports the
following function.
def getHead(self):
return self.head # it points to a Node
structure
The Node structure supports the following functions.
def getData(self):
return self.data # it returns the value
stored in the Node
def getNext(self):
return self.next # it points to the next
Node
b) Write a function that counts the number of times a given
integer occurs in a Linked List. Assume similar structures as
defined in (1).
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply