Code for Finding the Length of a List
by Dinesh[ Edit ] 2013-12-24 18:51:59
Code for Finding the Length of a List
int length(Node h) {
int count = 0;
for(Node p = h.next ; p!=null; p = p.next) {
++count;
}
return count;
}
You would call the method like this:
int n = length(head);