Year 7TechnologySupport
A bug is a mistake that makes an algorithm do the wrong thing. To find bugs, trace the algorithm: follow it one step at a time and write down the value of each variable as it changes. When you fix a bug, say what was wrong and write the corrected step.
ABugs and variables
- 1.
What is a bug in an algorithm?
1 mark- A mistake that makes the algorithm do the wrong thing
- A virus someone sends to your computer
- The part of a computer that stores files
- A message that shows when a program has finished
- 2.
What is a variable?
1 mark- A named store that holds a value which can change
- A step that is always repeated
- A question with a yes or no answer
- The last step of an algorithm
- 3.
Trace this algorithm and fill in the ? boxes in the trace table. Step 1: Set apples to 3. Step 2: Add 2 to apples. Step 3: Add 4 to apples.
2 marksTrace table
Step apples 1 3 2 ? 3 ? Draw or label here - 4.
Match each bug to its name.
4 marks- the steps are in the wrong order
- a step has been left out
- the loop never stops
- the robot turns 45 degrees when it should turn 90 degrees
- Asequence bug
- Binfinite loop
- Cmissing step
- Dwrong value
BFind and fix
- 5.
This algorithm is for getting ready to swim: 1. Get in the pool. 2. Put on your togs. 3. Walk to the pool. What is the bug? Write the steps in the right order. Sentence starter: "The bug is ... The right order is ..."
2 marks - 6.
This algorithm should get a letter posted: 1. Pick up the letter. 2. Walk to the postbox. 3. Walk back home. Which step is missing, and where does it go?
2 marks - 7.
This algorithm should make a robot clap 5 times: "Repeat 3 times: clap." Fix the bug.
1 mark - 8.
Testing an algorithm with several different inputs can help you find bugs.
1 mark- True
- False