top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

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

+3 votes
205 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 Google+ Share Button LinkedIn Share Button Multiple Social 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

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...