This problem can be easily solved by using simple recursion and again creates a basis for solving subset of related coding problems.
Possible solution:
Possible solution:
public int getLength(Node head)
{
if (head == null)
return 0;
else
return length(head.next) + 1;
}