Technical Interview

Tips, questions, answers and puzzles at
www.technical-interview.com

Thursday, April 22, 2010

Calculate length of the linked list

Q:

Calculate length of the linked list

A:

public int getLength(Node head)
{
if (head == null)
return 0;
else
return length(head.next) + 1;

}

No comments:

Post a Comment