Writing a bug report from a trace

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Writing a bug report from a trace

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which bug report is complete?
A The algorithm is broken and gives the wrong answer. Please fix it.
B Input 5. Expected 15, actual 20. Row 3 of the trace is wrong because total was not set to 0 first. Fix: add total <- 0.
2. Which sentence uses 'because' to explain the cause of a bug?
A Row 4 shows count is 5 because the line count <- count + 1 is inside the wrong loop.
B Row 4 shows count is 5. The loop is bad. Count is wrong.
3. Which one is evidence from the trace table?
A I think the algorithm looks a bit strange.
B In row 2, x is 7 but it should be 6.
4. Which part of a bug report states the expected and actual output?
A Expected: 12. Actual: 10.
B Fix: change > to >=.
5. Which is the best correction line for a bug report?
A Change the condition from score > 50 to score >= 50.
B Change something in the IF line so it works.

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Input: 4 and 6 AIt is wrong because total was not set to 0 first.
2Expected: 10, Actual: 14 BRow 1: total shows 4 but should be 0 + 4
3Point to the trace row where the value first goes wrong, as evidence from the trace table CToo vague. It gives no input, no expected or actual output and no trace row. Fix it by naming all of these.
4Explain the cause to a classmate using a because sentence DThe correction does not say which step to change or what to change it to. Fix it by naming the step and the new version.
5Bug: my algorithm does not work. EStates the input used when the test was run
6Row 3 is wrong. Fix: change the code. FCompares the expected output with the actual output

Definitions

bug report

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Input used: 4 ________ output: 10 Actual output: 14
2.
Input used: 4 Expected output: 10 ______ output: 14
3.
Input used: 4, expected output: 10 Evidence: the _____ table, row 3, total = 14
4.
Row 3: total = 14, expected 10 Cause: total is wrong _______ it starts at 4
5.
Cause: total starts at 4, not zero Fix: add total ← _ before the loop

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Input: 4 and 6
B Expected output: 5
C Actual output: 5
D Row 3: total never divided
E Fix: OUTPUT total / count
Question 2
A Input: 0 correct answers
B Expected output: 3
C Actual output: 1
D Row 3: score reset to 0
E Cause: SET score inside loop
Question 3
A Input: 5
B Expected: 5 stars
C Actual: 6 stars
D Cause: loop repeated 4 times
E Fix: use i < 5 not i <= 5
Question 4
A Input: mark is 50
B Expected output: Fail
C Actual output: Fail
D Row 2: 50 > 50 is false
E Fix: use >= instead of >
Question 5
A Input: 2, 3, 5
B Expected output: 9
C Actual output: 109
D Row 1: total starts at 100
E Fix: SET total TO 0 first

Answer Key

Writing a bug report from a trace
Section A: Quick Questions
Q1
B — Input 5. Expected 15, actual 20. Row 3 of the trace is wrong because total was not set to 0 first. Fix: add total <- 0.
Q2
A — Row 4 shows count is 5 because the line count <- count + 1 is inside the wrong loop.
Q3
B — In row 2, x is 7 but it should be 6.
Q4
A — Expected: 12. Actual: 10.
Q5
A — Change the condition from score > 50 to score >= 50.
Section B: Match the Pairs
Q1
Input: 4 and 6 → States the input used when the test was run
Q2
Expected: 10, Actual: 14 → Compares the expected output with the actual output
Q3
Point to the trace row where the value first goes wrong, as evidence from the trace table → Row 1: total shows 4 but should be 0 + 4
Q4
Explain the cause to a classmate using a because sentence → It is wrong because total was not set to 0 first.
Q5
Bug: my algorithm does not work. → Too vague. It gives no input, no expected or actual output and no trace row. Fix it by naming all of these.
Q6
Row 3 is wrong. Fix: change the code. → The correction does not say which step to change or what to change it to. Fix it by naming the step and the new version.
Section C: Definitions
Q1
bug report — A short note giving the input used, the expected and actual output, the trace row where it goes wrong, the cause and the correction. Use 'because' to explain the cause to a classmate.
Section D: Fill in the Blanks
Q1
Input used: 4 Expected output: 10 Actual output: 14
Q2
Input used: 4 Expected output: 10 Actual output: 14
Q3
Input used: 4, expected output: 10 Evidence: the trace table, row 3, total = 14
Q4
Row 3: total = 14, expected 10 Cause: total is wrong because it starts at 4
Q5
Cause: total starts at 4, not zero Fix: add total ← 0 before the loop
Section E: Spot the Error
Q1
C — A bug report must give the actual output, and it must differ from the expected output. Here the actual output should be 10, because the total was never divided by the count.
Q2
A — The input line must match the rest of the report. An expected output of 3 only makes sense if the input was 3 correct answers, not 0.
Q3
D — The cause must explain the actual output. 6 stars means the loop ran 6 times, so the line should say 6 times, not 4.
Q4
B — Expected output is what should happen, so it must differ from the actual output. A mark of 50 should give Pass, so the line should be 'Expected output: Pass'.
Q5
A — The input must match the expected output. 2 + 3 + 5 is 10, not 9, so the input should be 2, 3, 4.