I know people usually ask this question the other way round, but I have the following problem: I have this iterative function which counts all the nodes in a circular doubly
I think this should work (but note that it requires an extra argument for tracking start):
int count(node *start)
{
return count_helper(start, start);
}
int count_helper(node *current, node *start)
{
int c;
c = 0;
if(current == NULL)
return 0;
if((current->roll_no) == 20)
c = 1;
if(current->next == start) return c;
return (c + count_helper(current->next, start));
}