0
0
DSA Typescriptprogramming~5 mins

DP vs Recursion vs Greedy Choosing the Right Tool in DSA Typescript - Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is recursion in problem solving?
Recursion is a method where a function calls itself to solve smaller parts of a problem until it reaches a simple base case.
Click to reveal answer
intermediate
What does DP (Dynamic Programming) do differently from simple recursion?
DP stores results of solved subproblems to avoid repeating work, making it faster than simple recursion for problems with overlapping subproblems.
Click to reveal answer
beginner
When is a greedy algorithm the right choice?
A greedy algorithm works best when making the best local choice at each step leads to the best overall solution, without needing to reconsider previous choices.
Click to reveal answer
intermediate
What kind of problems are best solved by DP rather than greedy?
Problems with overlapping subproblems and optimal substructure, where local choices alone don’t guarantee the best global solution, are best solved by DP.
Click to reveal answer
intermediate
How can you decide between recursion, DP, and greedy for a new problem?
Check if the problem has overlapping subproblems and optimal substructure (use DP), if local best choices lead to global best (use greedy), or if it’s simple and small (recursion may be enough).
Click to reveal answer
Which approach stores results to avoid repeated work?
ABrute Force
BSimple Recursion
CDynamic Programming
DGreedy Algorithm
When is a greedy algorithm NOT suitable?
AWhen problem has no overlapping subproblems
BWhen local choices don’t guarantee global best
CWhen problem is very small
DWhen recursion is easy to implement
What is a base case in recursion?
AThe simplest case that stops recursion
BThe largest input size
CA repeated subproblem
DA greedy choice
Which property means a problem can be broken into smaller similar problems?
ABase case
BGreedy choice property
CRecursion depth
DOptimal substructure
What is overlapping subproblems in DP?
AWhen the same subproblems appear multiple times
BWhen subproblems are all different
CWhen greedy choices overlap
DWhen recursion never ends
Explain how to choose between recursion, dynamic programming, and greedy algorithms for solving a problem.
Think about problem structure and if repeated work happens.
You got /5 concepts.
    Describe the main difference between dynamic programming and greedy algorithms.
    Focus on how each approach makes decisions.
    You got /4 concepts.