For an unordered linked-list, write an algorithm called count which will count t
ID: 3570403 • Letter: F
Question
For an unordered linked-list, write an algorithm called count which will count the number of occurrences of a specific piece of data.
use 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.hed = None
Explanation / Answer
Class Node:
def __init__(self,initdata):
self.data = initdata
self.next = none
Class UnorderedList:
def __init__(self):
self.head = None
def __count__(searchData):
temp = self.head
count = 0
while (temp != none):
if (temp.data == searchData):
count = count +1
temp = temp.next
return count
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.