KTU S1

The Brute-Force Approach

By the end you should be able to: Describe the brute-force approach, apply it to the padlock and password examples, and judge when exhaustive search is and is not practical.

Brute force means: generate every possible candidate and test each one until you find the answer.

It is Module 1's trial and error, made systematic. Nothing clever, no insight into the problem — just complete enumeration.

Why it deserves a name

Two genuine strengths:

1. It always works. If a solution exists in the search space, brute force will find it. No approach that prunes candidates can promise that without proof.

2. It is easy to get right. There is no subtle logic to be wrong about, which makes it the natural baseline: solve it by brute force first, and use that to check any cleverer method you write later.

Its weakness is a single number: the size of the search space.

Example 1: the padlock

A 3-dial padlock, each dial 0–9:

10×10×10=1,000 combinations10 \times 10 \times 10 = 1{,}000 \text{ combinations}

At 2 seconds per attempt that is about 33 minutes. Tedious, but a person could do it.

Add dials and the space multiplies:

DialsCombinationsAt 2 s each
31,00033 minutes
410,0005.6 hours
61,000,00023 days
8100,000,0006.3 years

The method never changed. Only the search space grew — and that alone moved it from practical to impossible.

Example 2: password guessing

Same arithmetic, and the reason password advice is what it is.

For an alphabet of size aa and length LL, the space is aLa^L.

PasswordSpaceAt 1 billion guesses/sec
4 digits10410^4 = 10,000instant
6 lower-case letters266≈3.1×10826^6 \approx 3.1 \times 10^8under a second
8 lower-case letters268≈2.1×101126^8 \approx 2.1 \times 10^{11}~3.5 minutes
8 mixed case + digits + symbols≈6.1×1015\approx 6.1 \times 10^{15}~71 days
12 mixed case + digits + symbols≈4.8×1023\approx 4.8 \times 10^{23}~15 million years

(Taking a 94-character alphabet: 26 lower, 26 upper, 10 digits, 32 symbols.)

Length matters more than complexity, because length is the exponent. Each extra character multiplies the space by the alphabet size; each extra symbol type only enlarges the base.

This is why brute force is a security concept as much as an algorithmic one — the defence is making the search space too large, not making the method fail.

When brute force is the right choice

  • The search space is small (a few thousand candidates)
  • Testing one candidate is cheap
  • You need a guaranteed answer, not a good-enough one
  • You are checking a cleverer algorithm against a known-correct baseline
  • The problem is one-off — an hour of computer time beats a day of your thinking time

When it is not

  • The space grows exponentially with input size
  • Each test is expensive
  • A near-optimal answer would do — then use a heuristic (Module 1)

The connection back to Module 1

Trial and error needed a small search space, cheap testing, and no better information. Brute force is the same three conditions, applied systematically rather than randomly — which guarantees you neither repeat a candidate nor miss one.