This will be in Python We have used the node structure and a linked-list structu
ID: 670386 • Letter: T
Question
This will be in Python
We have used the node structure and a linked-list structure as shown below:
Class Node:
def __init__(self,initdata):
self.data = initdata
self.next = none
Class UnorderedList:
def __init__(self):
self.head = None
Now, for an unordered linked-list, I need to write an algorithm called count which will count the number of occurrences of a specific piece of data. If you could add in notes and have proper indentation that would be very helpful.
Thank you
Explanation / Answer
Class Node:
def __init__(self,initdata):
self.data = initdata
self.next = none
Class UnorderedList:
def __init__(self):
self.head = None
def count(self,data):
temp = self.head
count = 0
while temp != null:
if temp.data == data:
count = count + 1
temp = temp.next
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.