What is the recursion?Recursion is an approach in which a function calls itself with an argument. Upon reaching a termination condition, the control returns to the calling function.Explain the terms Base case, Recursive case, Binding Time, Run-Time Stack and Tail Recursion.Base case: A case in recursion, in which the answer is known when the termination for a recursive condition is to unwind back.
Recursive Case: A case which returns to the answer which is closer.
Run-time Stack: A run time stack used for saving the frame stack of a function when every recursion or every call occurs.
Tail Recursion: It is a situation where a single recursive call is consisted by a function, and it is the final statement to be executed. It can be replaced by iteration.Explain the terms Base case, Recursive case, Run-Time Stack and Tail Recursion.Base case: - In this case, the output is known or when using recursion, the termination condition which restarts the function is called as base case.
Recursive case: - A case which brings user to the closest answer.
Binding time:-
Run-Time Stack: - Run Time stack contains return address, local variables and return value if any of a recursive function call.
Tail Recursion: - Tail recursion consists of one recursive call with the last statement to be executed. To find factorial of a given number is an example of tail recursion. .
|