0
0
DSA Typescriptprogramming~5 mins

Memoization to Optimize Recursion in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is memoization in the context of recursion?
Memoization is a technique to store the results of expensive function calls and reuse them when the same inputs occur again, avoiding repeated calculations.
Click to reveal answer
beginner
How does memoization improve recursive function performance?
By saving results of subproblems, memoization prevents the function from recalculating the same values multiple times, reducing time complexity from exponential to linear in many cases.
Click to reveal answer
beginner
In TypeScript, what data structure is commonly used to implement memoization?
A JavaScript object or Map is commonly used to store computed results with input parameters as keys for quick lookup.
Click to reveal answer
intermediate
Explain with a simple example how memoization works in a Fibonacci recursive function.
In a Fibonacci function, memoization stores the result of fib(n) after computing it once. When fib(n) is needed again, the stored value is returned immediately instead of recalculating fib(n-1) and fib(n-2).
Click to reveal answer
intermediate
What is the difference between memoization and tabulation?
Memoization is a top-down approach that caches results during recursion, while tabulation is a bottom-up approach that builds a table iteratively without recursion.
Click to reveal answer
What does memoization primarily help to reduce in recursive functions?
ANumber of function parameters
BRepeated calculations of the same subproblems
CMemory usage by deleting variables
DCode length
Which data structure is best suited for memoization in TypeScript?
AMap or Object
BArray
CSet
DString
What is the time complexity improvement when using memoization on Fibonacci recursion?
AFrom O(n) to O(1)
BNo improvement
CFrom O(2^n) to O(n)
DFrom O(n^2) to O(n^3)
Memoization is an example of which programming technique?
AGreedy algorithm
BBrute force
CDivide and conquer
DDynamic programming
Which of the following is NOT true about memoization?
AIt always reduces space complexity
BIt uses extra memory to store results
CIt avoids repeated recursive calls
DIt can be implemented using a cache
Describe how memoization optimizes a recursive Fibonacci function.
Think about how repeated calls to fib(n) are handled.
You got /4 concepts.
    Explain the difference between memoization and tabulation in dynamic programming.
    Consider the order of solving subproblems.
    You got /4 concepts.