DSA Problem Solving Strategies Flashcards
What is the difference between Brute Force and Divide & Conquer?
Brute Force checks all cases, Divide & Conquer splits into subproblems.
When should you use Greedy instead of Dynamic Programming?
Greedy makes immediate decisions; DP considers future consequences.
How do you decide whether to use BFS or DFS?
BFS is better for shortest paths; DFS is better for tree traversal.
How do you optimize a recursive function to avoid stack overflow?
Use Tail Recursion or convert to iteration
How do you approach a problem when no obvious algorithm applies?
Start with brute force, analyze constraints, refine approach.
How do you decide which data structure to use in a problem?
Consider operations’ time complexity and problem constraints.
What is the engineering method?
Explore - identify and clarify, Brainstorm - what are differnt ways I can solve? Plan - Choose most viable option. Implement- apply the option. Verify - TEST!!!