Welcome! Today we will become code detectives and learn how to debug algorithms.
An algorithm is a step-by-step list of instructions for a computer. A bug is an error in those instructions that makes the program fail.

Debugging means finding and fixing errors in your code. We test each step one by one to see where things go wrong.
To debug effectively, trace your program carefully. Compare what your code actually does with what you wanted it to do.
✏️ Worked example
Debug this algorithm for making cereal: 1. Pour milk into bowl. 2. Eat cereal. 3. Pour cereal into bowl.
- Read through all the steps in order.
- Identify the error: Step 2 tells you to eat before adding cereal.
- Remove the incorrect step placement.
- Reorder the steps: 1. Pour cereal, 2. Pour milk, 3. Eat cereal.
- Test the new sequence to confirm it works.

Want the full interactive lesson — quiz, animations, and Finn cheering them on?