Pattern Recognition

⏱ 7 min✏️ Quiz at the end

Seen This Before?

Pattern recognition means spotting similarities, repetition, and trends β€” in data, in problems, or between a new problem and one you have already solved.

It is the second tool of computational thinking, and your brain is already brilliant at it: you recognise faces, song choruses, and the fact that every Monday starts with assembly.

Why Patterns Matter

The moment you spot a pattern, you gain two superpowers:

  1. Reuse β€” solve the problem once, then apply the same solution to every case that fits the pattern
  2. Prediction β€” if the pattern has held so far, you can predict what comes next

Without pattern recognition, every problem must be solved from scratch. With it, most "new" problems turn out to be old problems in disguise.

Patterns in Numbers

Number sequences are the classic warm-up:

SequencePatternNext term
2, 4, 6, 8, …add 210
1, 2, 4, 8, 16, …double32
1, 4, 9, 16, 25, …square numbers36

Finding the rule behind the sequence is exactly what a computer scientist does β€” the rule is the reusable part.

Patterns in Problems

Suppose your class must draw 20 snowmen. Every snowman needs:

  • a large snowball for the body
  • a smaller snowball for the head
  • two eyes, one carrot nose, one hat

That shared structure is the pattern. Instead of 20 separate drawing plans, you write one algorithm β€” "draw body, draw head, add eyes, nose, hat" β€” and repeat it 20 times. Pattern recognition is what turns repetition from boring into powerful.

Patterns in Data

Computers are extraordinary at finding patterns in data far too large for humans to scan:

  • Shops spot that umbrella sales rise when rain is forecast β€” and stock up
  • Doctors use software that spots patterns in scans linked to illness
  • Streaming services notice you like certain kinds of shows and recommend similar ones

In every case the logic is the same: find what repeats in the past, use it to predict the future. One caution: a pattern is evidence, not proof β€” predictions from patterns can still be wrong.

Working With Decomposition

Pattern recognition teams up naturally with decomposition:

  1. Decompose the big problem into parts
  2. Compare the parts β€” which ones look similar?
  3. Solve the shared pattern once, and reuse the solution for every matching part

If three parts of your project all involve "get a list of names and sort it", that is one solution used three times β€” a third of the work.

Worked Example β€” Marking a Set of Tests

Imagine you must mark 30 test papers, each with 10 questions. Look for the pattern before marking a single one:

  • Every paper has the same 10 questions, in the same order
  • Each question has one correct answer from a fixed list
  • The final mark for each paper is just the count of correct answers

Spotting this pattern means you never need a fresh marking plan per student. Instead you build one answer key and one rule ("compare each answer to the key, count matches") and apply it 30 times β€” exactly the "solve once, reuse everywhere" superpower from earlier in this lesson. This is also precisely how a computer would mark the same test automatically: the pattern you noticed by eye is the same one a marking algorithm would be built around, using a loop to go through each paper and a condition to check each answer.

Patterns Can Mislead You

Pattern recognition is powerful, but it comes with a genuine trap: seeing a pattern does not prove it will continue. A shop that has sold more ice cream every June for five years is reasonably confident June six will be similar β€” that is a fair use of pattern recognition. But a gambler who has seen a coin land heads five times in a row and now expects tails is falling for a famous mistake: each flip is independent, and the "pattern" of five heads has no bearing on the sixth flip at all. The difference matters: the ice cream pattern has an underlying cause (June is summer, people want ice cream); the coin "pattern" has no cause connecting one flip to the next. Before trusting a pattern to predict the future, it is worth asking: is there a real reason this pattern should continue, or have I just noticed a coincidence?

Key Words

  • Pattern β€” something that repeats or stays similar across cases
  • Pattern recognition β€” spotting those repetitions and similarities
  • Prediction β€” using a pattern from the past to estimate what comes next
  • Reuse β€” applying one solution to every case that matches the pattern