✦
✦
Computer Science · Coding Basics
Algorithms and Debugging
A computer follows instructions. Describe each step of the task in an algorithm, then check the order.
🤖An Algorithm Is a Set of Steps
🔢Putting steps in order
✅Right order
1Get two slices of bread
2Spread peanut butter on one
3Spread jelly on the other
4Press the slices together
🥪Sandwich assembled
🐞Steps to debug
1Press the slices together
2Spread jelly on the outside
3Put the entire peanut butter jar on top
4Get the bread after assembling it
🤖The sandwich does not come out as intended.
PSEUDOCODE
1GET 2 slices of bread2SPREAD peanut butter on slice A3SPREAD jelly on slice B4PUT slice A onto slice B5SHOW "Sandwich is ready!" 🥪
🔧Bugs & Debugging
Run, check, fix and run again
▶️ Run the program and watch what it does
🔍 Spot the bug. Which step produced an unexpected result?
🐞 The bug is the mistake in your steps
🔧 Fix it and run the program again to check the change.
🔑Key Terms
📋Algorithm A list of steps to finish a task or solve a problem.
🔢Sequence The exact order in which steps or events happen.
🐞Bug An error in a program that stops it working right.
🔧Debug To find and fix the bugs in a program.
💾Program An algorithm coded so a machine can run it.
📝Pseudocode A description of a program’s steps in words or simple code-like notation.
⭐
Test the sandwich instructions in order. If a step uses something the previous steps have not prepared, revise it and try again.
✏️ Computer Science Anchor Chart · Thinking Like a Computer