in C write an algorithm to count the nodes in a linked list
in C++, write an algorithm to count the nodes in a linked list with first node pointed to by first
Solution
Answer:
The algorithm to count the nodes in a linked list with first node pointed to by first is given as below :
void count()
{
struct node *support;
int size = 0;
support = first;
while(support!=NULL)
{
size++;
support=support->next;
}
cout<<\"Number of nodes of Linked List is :\"<<size;
}
