Reputation: 1445
I cant figure out where do we use this structure for recursion in a problem and what is this called
int func001(int x){
if(x>=1) func003(x-1);
}
int func003(int y){
if(y>=2) func001(y-1);
}
Upvotes: 1
Views: 48
Reputation: 6468
This kind of recursion is called mutual recursion. Your code example is not well defined, so it is not possible to tell what is here intended.
Nevertheless, the most common use of mutual recursive functions is to encode a finite state automaton: each state is represented by a function and transitions are represented by calls to other functions. This is for instance the case in lexical analysers generated by lex
and similar programs, but also often the case in hand-written lexical analysers.
Upvotes: 1