Skip to main content
AP CSP course

F03 · Topic 1.4

Bug clinic

Compare a faulty threshold counter with its specification, isolate a defect and design tests that expose it.

1. Predict first

For values[5,5,1], minimum 5, predict an inclusive counter, a strict-greater counter and a counter reset inside each iteration.

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to experiment
  1. Input 15,5,1Waiting
  2. Input 25Waiting
  3. Input 3boundaryWaiting

Ready to experiment

Why: Predict the first change, then advance one step.

Try this: Try repeated boundary values, no matches and an empty list.

2. Build your procedure

Write countAtLeast(values,minimum) with initialization outside the loop and return after the loop. Show one test exposing each of the two faulty versions.

Use AP CSP pseudocode, a language you know, or precise plain language. Your code is not executed here. Use the classroom assignment to save your response.

3. Check boundaries

Public worked tests for the fixed model
InputExpectedWhy this case
[5]; minimum 5; boundary faultCorrect 1, faulty 0Equality exposes the strict comparison.
[6,6]; minimum 5; reset faultCorrect 2, faulty 1Two matches expose lost accumulation.
[]; minimum5Correct0Initialize and return even when the loop has no iterations.

4. Explain and reflect

Why is changing two suspicious lines at once weaker evidence about the cause than isolating one change and retesting?

Model limits: Compares two named faulty counter models with a fixed correct model. A successful test set is not a proof that arbitrary code is correct.

Teacher guidance and scoring