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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Sep 28, 2014, 3:08 AM EDT
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.
VulpesRank #55 · 29.2K reputationPosted Sep 27, 2014, 11:42 AM EDT
Joe WilsonRank #631 · 3.8K reputationPosted Sep 27, 2014, 10:45 PM EDT
I don't understand the codes below.