Code for Finding the Length of a List

by Dinesh 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);

Tagged in:

914
like
0
dislike
0
mail
flag

You must LOGIN to add comments