Recursive method counting

  c++

How does this recursive integer method count the number of nodes in a linked list? How can a constant 1 be added to a memory address?

int length(Node *head) {
  if(head == nullptr)
    return 0;

  return 1 + length(head->link);
}

Source: Windows Questions C++

LEAVE A COMMENT