- Home
- /
- CS Thinking
- /
- Mistakes
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.
The goal of this page is to expose the wrong mental model early. Once you can name the temptation behind the 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
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.
Testing the procedure on only one easy example
Trace the algorithm with several inputs, including unusual or boundary cases, before assuming it is correct.
Forgetting to define the input and output clearly
Start by naming what goes into the algorithm and what result should come out.
Ignoring what should happen when the input is empty or invalid
Good algorithms describe how to handle special cases, not just the normal path.
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
- โข Replace words like "sort it" or "fix it" with exact actions the machine can perform.
- โข Trace the algorithm with several inputs, including unusual or boundary cases, before assuming it is correct.
- โข Start by naming what goes into the algorithm and what result should come out.