0
0
DSA Typescriptprogramming~5 mins

Fibonacci Using DP in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main idea behind using Dynamic Programming (DP) to calculate Fibonacci numbers?
DP stores the results of smaller subproblems (previous Fibonacci numbers) to avoid repeated calculations, making the process faster and efficient.
Click to reveal answer
beginner
In Fibonacci DP, what does the 'memoization' technique mean?
Memoization means saving the result of each Fibonacci number once calculated, so if we need it again, we just reuse it instead of recalculating.
Click to reveal answer
intermediate
What is the time complexity of Fibonacci calculation using DP?
The time complexity is O(n) because each Fibonacci number from 0 to n is calculated once and stored for reuse.
Click to reveal answer
beginner
Why is the simple recursive Fibonacci approach inefficient compared to DP?
Simple recursion recalculates the same Fibonacci numbers many times, causing exponential time complexity, while DP avoids this by storing results.
Click to reveal answer
beginner
Show the base cases used in Fibonacci DP and explain why they are important.
Base cases are Fib(0) = 0 and Fib(1) = 1. They stop the recursion and provide starting points to build all other Fibonacci numbers.
Click to reveal answer
What does DP store to optimize Fibonacci calculation?
APreviously calculated Fibonacci numbers
BRandom numbers
COnly the last Fibonacci number
DNo values, it recalculates every time
What is the time complexity of Fibonacci using DP?
AO(n)
BO(2^n)
CO(log n)
DO(n^2)
Which technique is used in DP to save results of subproblems?
AGreedy
BBacktracking
CMemoization
DBrute force
What are the base cases for Fibonacci DP?
AFib(1) = 1 and Fib(2) = 2
BFib(0) = 0 and Fib(1) = 1
CFib(0) = 1 and Fib(1) = 1
DFib(2) = 1 and Fib(3) = 2
Why is simple recursion inefficient for Fibonacci?
AIt only works for small numbers
BIt uses too much memory
CIt does not return correct results
DIt recalculates the same values many times
Explain how Dynamic Programming improves Fibonacci number calculation compared to simple recursion.
Think about how saving answers helps avoid doing the same work twice.
You got /4 concepts.
    Describe the role of base cases in the Fibonacci DP approach and why they are necessary.
    Base cases are like the first steps in a staircase you need to climb.
    You got /4 concepts.