Problem Solving Strategies Flashcards
What is the difference between Brute Force and Divide & Conquer?
Brute Force checks all cases, Divide & Conquer splits into subproblems.
How do you decide whether to use BFS or DFS?
BFS is better for shortest paths; DFS is better for tree traversal.
When should you use Greedy instead of Dynamic Programming?
Greedy makes immediate decisions; DP considers future consequences.
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, Brainstorm - consider solutions, Plan - choose best option, Implement, Verify - TEST!
What kind of solution should you think about when you here “optimal”, “minimization”, or is an interval or event scheduling platform?
GREEDY
When is topological sort useful? (Kahns Algo)
Task scheduling (e.g., prerequisites in course scheduling)
Dependency resolution (e.g., package managers like npm, pip)
Compiling dependencies in a build system
Deadlock detection (e.g., circular dependencies)