This is an algorithm to count total number of nodes in a linked list.
1. ptr = start, count = 0
2. while ptr <> NULL do steps 3 and 4
3. count = count+1
4. ptr = ptr -> link
5. print "No of Nodes", count.
This is an algorithm to count total number of nodes in a linked list.
1. ptr = start, count = 0
2. while ptr <> NULL do steps 3 and 4
3. count = count+1
4. ptr = ptr -> link
5. print "No of Nodes", count.