KTU S1

Trial and Error

By the end you should be able to: Explain what makes trial and error a legitimate strategy, identify the conditions under which it is appropriate, and recognise when it is the wrong tool for a problem.

Trial and error means generating a possible solution, testing it, and — if it fails — trying another. Keep going until something works.

Students often assume this is what you do when you don't know the proper method. That's the wrong way to think about it. Trial and error is a genuine strategy with a precise domain of usefulness, and knowing that domain is the examinable part.

When it is the right tool

Trial and error works when three things are true at once:

  1. The search space is small enough. Four possible answers, fine. Ten billion, not fine.
  2. Testing a candidate is cheap. You must be able to check "is this right?" quickly and without damage.
  3. You have no better information. Nothing about the problem tells you which candidates are more promising than others.

A padlock with three dials of ten digits each has 1,000 combinations. Tedious, but a person could do it. Add three more dials and it becomes 1,000,000 — the same strategy, now useless. Nothing about the method changed; the size of the search space did.

The characteristic weakness

Trial and error carries no memory and no reasoning. A failed attempt teaches you only that one candidate was wrong. It doesn't narrow the field, and it doesn't suggest what to try next.

That's exactly what separates it from a heuristic. A heuristic uses information about the problem to choose the next guess intelligently. Trial and error simply guesses again.

Where you'll actually meet it

  • Password guessing and brute-force attacks — the security case
  • Finding which component of a circuit has failed, by swapping one at a time
  • Tuning a value in a program when you have no formula for it
  • Debugging, when you genuinely have no hypothesis (though a hypothesis is always better)

One caution

"Systematic" trial and error — going through candidates in a fixed order so you never repeat and never skip — is much stronger than random guessing. It guarantees you'll find the answer if one exists in the space. Random guessing guarantees nothing.