← Lessons

quiz vs the machine

Silver1040

Algorithms

The Brute Force Baseline

Why trying every possibility is the honest starting point for any algorithm.

4 min read · intro · beat Silver to climb

Start by trying everything

A brute force algorithm solves a problem by enumerating every candidate solution and checking each one against the requirements. It makes no clever observations about structure. For a password of fixed length it tries all combinations; for a path problem it lists all paths and keeps the best.

Why it matters as a baseline

Brute force is rarely the final answer, but it is the most valuable first answer:

  • It is easy to reason about, so it is easy to get correct.
  • It defines the exact specification every faster algorithm must match.
  • It gives you a slow but trustworthy reference to test optimized code against.

Where it breaks down

The trouble is scale. The number of candidates often grows exponentially or factorially with input size, so a brute force solution that works on ten items can be hopeless on forty. Recognizing that explosion is what motivates the smarter paradigms: greedy choices, divide and conquer, and dynamic programming all exist to avoid examining every candidate.

Key idea

Brute force enumerates every candidate and is usually too slow to ship, but it is the correct, easy to verify baseline that every faster algorithm must agree with.

Check yourself

Answer to earn rating on the learn ladder.

1. What is the main practical value of a brute force solution?

2. Why does brute force often fail at scale?