A girl and a robot thinking together

Let’s think it through · Start with a story

The rules of a complicated card game are hard to follow, so the girl starts with just one card, then adds a second and a third.

Break down the process

Follow the numbered steps, then explain them in your own words
  1. One cardThe result is immediate
  2. Two cardsThe first comparison is needed
  3. Three cardsCheck whether the rule still works
  4. More cardsLook for a general pattern

Starting with the smallest input can reveal initialization, boundaries, and recurrence relations.

Small examples do not replace solving the full problem. They help you find a reason that can be generalized.

01Why look at small inputs first?

With little data, you can work through the entire process by hand.

For example, sorting 10,000 numbers on paper is hard, but sorting 3 numbers is easy.

02What can the simplest case tell us?

Rules

How does the problem actually work?

Boundaries

What about 0 or 1 element?

Patterns

How does the answer grow with the input size?

Mistakes

Does your interpretation have contradictions?

03Why does recursion especially need a simplest case?

Recursion must have a base case.

For example:

factorial(0) = 1

The simplest case is where the recursive breakdown stops.

04Does dynamic programming need one, too?

Yes. Dynamic programming often builds answers starting from the smallest states.

We will study DP in more depth later on this site, but it is important to build the habit of clarifying the smallest case now.

05Can simple cases be misleading?

They can.

A pattern found in just one small example may not hold for every input, so you need more examples and a proof.

06How should you choose small examples?

Do not choose only one ordinary example. Also include:

  • The smallest input
  • Equal values
  • Extreme orderings
  • Cases near a boundary

What you have learned

  • Small inputs are easier to simulate and verify by hand.
  • The simplest case can reveal rules and boundaries.
  • Recursion and dynamic programming often depend on base cases.
  • Small examples can help you guess a pattern but cannot replace a proof.
  • Deliberately create several different kinds of small examples.

Next: Stuck? Try Brute Force First

Your turn

Can testing a sorting algorithm with only one card reveal that the swap order is reversed?

Have an answer? Click to see the explanation

Usually not, because no swap is needed. Also test two cards in reverse order and larger cases.