Skip to main content
AP CSP course

F16 · Topic 3.13

Reusable recommendation procedure

Develop a reusable inclusive-range recommendation filter with a list parameter and two bounds; demonstrate that the parameters change behaviour.

1. Predict first

Recommend values from low through high inclusive. Predict results for[1,5,8,5,10], bounds 5…8 and then 8…10.

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 11,5,8,5,10Waiting
  2. Input 25Waiting
  3. Input 38Waiting

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 recommend(values,low,high), using sequencing, selection and iteration. Return a new list and show two calls with different bounds. State a precondition for the bounds.

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
[1,5,8,5,10]; low 5,high 8[5,8,5]Both endpoints included.
Same list; low 8,high 10[8,10]A different interval reuses the same body.
[]; low5,high8[]No iteration is required.

4. Explain and reflect

Explain concretely how the procedure manages complexity compared with copied filters for every page.

Model limits: Runs a fixed range-filter model, not the student’s submitted procedure. Teacher review is needed to evaluate the actual code and explanation.

Teacher guidance and scoring