Common Mistakes in Algorithms

Algorithm questions often go wrong before any code is written. The usual problems are ambiguity, missing cases, or a procedure that only works on one example.

Why these errors repeat

Most algorithm errors are not careless slips. They happen when a shortcut feels close enough to the real idea that it seems safe to reuse. That is why patterns like writing steps that are too vague for a computer to follow or testing the procedure on only one easy example keep showing up even after more practice.

Once you can name the temptation behind a mistake, it becomes much easier to notice it in homework, tests and worked examples.

Quick checklist

  • Writing steps that are too vague for a computer to follow
  • Testing the procedure on only one easy example
  • Forgetting to define the input and output clearly
  • Ignoring what should happen when the input is empty or invalid
  • Confusing a single example with a general method

Where people get stuck

  1. 1.

    Writing steps that are too vague for a computer to follow

    Replace words like "sort it" or "fix it" with exact actions the machine can perform.

  2. 2.

    Testing the procedure on only one easy example

    Trace the algorithm with several inputs, including unusual or boundary cases, before assuming it is correct.

  3. 3.

    Forgetting to define the input and output clearly

    Start by naming what goes into the algorithm and what result should come out.

  4. 4.

    Ignoring what should happen when the input is empty or invalid

    Good algorithms describe how to handle special cases, not just the normal path.

  5. 5.

    Confusing a single example with a general method

    An algorithm must work for every valid input in its domain, not just one sample case.

Stuck?

Understanding the core concept helps you avoid these mistakes naturally.

See the core concept: Algorithm

Self-check before you submit

  • Before you move on, check whether you are writing steps that are too vague for a computer to follow.
  • Before you move on, check whether you are testing the procedure on only one easy example.
  • Before you move on, check whether you are forgetting to define the input and output clearly.

Related concepts