0
0
DSA Cprogramming~5 mins

Factorial Using Recursion in DSA C - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is recursion in programming?
Recursion is when a function calls itself to solve smaller parts of a problem until it reaches a simple case it can solve directly.
Click to reveal answer
beginner
What is the base case in a recursive factorial function?
The base case is when the input number is 0 or 1, and the factorial is 1. This stops the recursion from continuing forever.
Click to reveal answer
beginner
How does the factorial function call itself recursively?
The factorial function calls itself with the number minus one (n-1) and multiplies the result by n, building the factorial step by step.
Click to reveal answer
intermediate
What happens if a recursive function does not have a base case?
Without a base case, the function will keep calling itself forever, causing the program to crash or run out of memory.
Click to reveal answer
beginner
Write the recursive formula for factorial of n.
factorial(n) = n * factorial(n-1), with factorial(0) = 1
Click to reveal answer
What is the factorial of 0?
A1
B0
CUndefined
DFactorial of 0 does not exist
In a recursive factorial function, what stops the recursion?
ABase case
BLoop
CReturn statement
DFunction parameters
What does factorial(5) compute to?
A720
B25
C60
D120
Which of these is a correct recursive call in factorial function?
Afactorial(n+1)
Bfactorial(n*2)
Cfactorial(n-1)
Dfactorial(n/2)
What will happen if the base case is missing in recursion?
AFunction returns 1
BInfinite recursion and crash
CFunction returns 0
DProgram runs normally
Explain how a recursive factorial function works step-by-step for input 3.
Think about how the function calls itself and returns values.
You got /5 concepts.
    Describe why a base case is important in recursion and what it should be for factorial.
    Base case is the simplest problem answer.
    You got /4 concepts.