top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Write a function that counts the number of times a given int occurs in a Linked List?

+3 votes
583 views
Write a function that counts the number of times a given int occurs in a Linked List?
posted Apr 15, 2014 by Vishvachi Tiwari

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Just giving the algorithm of the problem as it is very simple -

  1. Initialize count as zero.
  2. Loop through each element of linked list:
    a) If element data is equal to the passed number then
    increment the count.
  3. Return count.
answer Apr 15, 2014 by Salil Agrawal
Similar Questions
+1 vote

Given a singly linked list of integers, write a function in java that returns true if the given list is palindrome, else returns false

+4 votes

Design an algorithm to accept a string from the user. Count and print the number of times each character occurs in the given string. Example –
input string = "malayalam"
Output must be –
m – 2
a – 4
l – 2
y - 1

...