+ 1
Pls I don't understand how this recursive function works. I mean the odd and even function. I can't get the logical view.
2 Answers
+ 1
*** Indirect Recursion
(also called Mutual Recursion)
def function_1():
# <base case>
# call function_2
def function_2():
# <base case>
# call function_1
- Indirect Recursion is the implementation of recursion which requires 2 or more functions calling each other until a base case in any function is met (note that backtracking will happen).
- When any base case in function 1 or 2 is met, the recursion tracks back.
- Base case could be met either in function 1 or 2.
- Function 1 will try to reach the base case of function 2; while function 2 tries to reach the base case of function 1.
- If there's only 1 base case - in function 1 for example, the function 1 try to reach its base case through calling function 2, which is in turn trying to reach the base case of function 1.
https://code.sololearn.com/cIeW1kpSQKJ1/?ref=app
+ 4
https://www.youtube.com/watch?v=c7VjS7ZZVWM