I mean I want to use Recursion function to count nodes of a link list.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Sep 28, 2014, 7:08 AM
So initially we pass the counter function a pointer to the first node and also a pointer to the position just after the last node.
The total number of nodes is 1 plus the number of nodes from the next position to the end. So we increment the pointer and call the counter function recursively until eventually we get to the end when the stack unwinds and we're left with 0 plus a series of 1's which add up to the number of nodes in the linked list.
Joe WilsonPosted Sep 28, 2014, 2:45 AM
I don't understand the codes below.
VulpesPosted Sep 27, 2014, 3:42 PM