Question
A linked list is formed from the objects of the class ,
class Node
{
int item;
Node next;
}
Write a method OR an algorithm to count the number of nodes in the linked list .The method declaration is specified below:
int count(Node ptr_start);
Share code with your friends
Share on whatsapp
Share on facebook
Share on twitter
Share on telegram
Code
int count(Node ptr_start)
{
Node temp=new Node(ptr_start);
int c=0;
while(temp!=null)
{
c++;
temp=temp.next;
}
return c;
}
Coding Store
Sale

ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale

ICSE QUESTION PAPER WITH SOLUTION(PROGRAMMING ONLY)
Sale

ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale

ICSE QUESTION PAPER WITH SOLUTION(PROGRAMMING ONLY)
Sale

ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale
