Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote