write an algorithm to count number of times a given ITEM occurs in a linked list L.
Answers
Answered by
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
Math,
27 days ago
India Languages,
27 days ago
English,
1 month ago
Math,
8 months ago
Physics,
8 months ago