Skip to main content

Strategy Beats Blind Search

What This Concept Is

Algorithm strategy is the high-level pattern you use to search for a solution. Common families include brute force, backtracking, heuristics, divide and conquer, and dynamic programming. They differ in how much of the search space they inspect and how much work they reuse.

Why It Matters Here

Two solutions can target the same problem but live in different universes of practicality. Strategy is where that difference often begins. If you can recognize the shape of a problem, you can often choose a strategy that avoids wasted work instead of simply coding faster.

Concrete Example

Consider a packing problem:

  • brute force checks every candidate combination
  • backtracking gives up early when partial choices already fail
  • a greedy heuristic picks what looks best now and keeps moving
  • dynamic programming reuses repeated subproblems

Or consider sorting:

  • naive repeated comparisons can lead to O(n^2) work
  • divide and conquer splits the list, solves smaller parts, then merges them back

The strategy changes the cost before the syntax changes.

Common Confusion / Misconception

Heuristics are not automatically sloppy, and brute force is not automatically wrong. Sometimes brute force is the only realistic exact method for small inputs. Sometimes a heuristic is the right business choice because "good enough soon" beats "perfect too late." The mistake is treating one family as universally best.

How To Use It

Ask these questions:

  1. Can I inspect all candidates, or is that too expensive?
  2. Can partial bad choices be rejected early?
  3. Does the problem split into similar smaller subproblems?
  4. Are the same subproblems being solved repeatedly?
  5. Is a near-optimal answer acceptable if it arrives much faster?
StrategyBest first signal
Brute forceSearch space is small enough or exactness is mandatory
BacktrackingPartial choices can be ruled out early
HeuristicFast good-enough answers beat perfect expensive ones
Divide and conquerThe problem splits cleanly into similar smaller ones
Dynamic programmingOverlapping subproblems are causing repeated work

Check Yourself

  1. What is the difference between backtracking and brute force?
  2. When is a heuristic the right choice even if it may miss the optimum?
  3. Why does memoization help some recursive problems so much?

Mini Drill or Application

Classify each problem with the strategy you would try first and explain why:

  • solving a small puzzle with very few combinations
  • finding a route through a huge space where perfect is not required
  • sorting a large list
  • optimizing a recursive solution that recalculates the same values many times

Your answer should name the signal that led to the strategy, not just the strategy name.

Read This Only If Stuck