xxxxxxxxxx
def size():
count = 0
current_node = linked_list.head
while(node != null):
counter += 1
current_node = current_node.next
return count
xxxxxxxxxx
public int getCountRec(Node node)
{
// Base case
if (node == null)
return 0;
// Count is this node plus rest of the list
return 1 + getCountRec(node.next);
}
xxxxxxxxxx
def lengthRecursive(head):
if head is None:
return 0
else:
return 1 + lengthRecursive(head.next)