Computer Science, asked by ranabarsha152, 2 months ago

write an algorithm to count number of times a given ITEM occurs in a linked list L. ​

Answers

Answered by umarfarooqshafi6564
3

Answer:

count = 0

while L contains node do

   if L->value == ITEM then

       count = count + 1

   end if

   L = L->next

end while

Explanation:

Let L = [1, 2, 3, 2, 2, 4, 5, 6] is a linked list

and you want to count how many times 2(ITEM) accours in L then

Output: 3

Similar questions