Modeling Examples in CS Thinking

Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Modeling.

This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in CS Thinking.

Concept Recap

Modeling is the process of building a simplified representation of a real system so you can study, predict, or explain its behavior. A model keeps the details that matter for the question and leaves out details that do not.

A model is a useful simplification. It is not reality itself, but a focused version of reality.

Read the full concept explanation →

How to Use These Examples

  • Read the first worked example with the solution open so the structure is clear.
  • Try the practice problems before revealing each solution.
  • Use the related concepts and background knowledge badges if you feel stuck.

What to Focus On

Core idea: Every model depends on assumptions, so good models must be checked against real data or known behavior.

Common stuck point: A model is not supposed to include everything. Its job is to include the right things.

Sense of Study hint: Start by naming the question the model should answer. Then choose the variables that matter most and write down the assumptions you are making before you trust the result.

Worked Examples

Example 1

medium
A traffic-light simulator uses 3 states (red, yellow, green) and fixed timers. State two assumptions baked into this model.

Answer

Fixed durations (ignores real demand-responsive lights); 3 discrete states (ignores arrow phases, flashing modes).

First step

1
Real lights often adapt to sensors — the timer model assumes a static schedule.

See the full worked solution + why-it-works coaching

SetupKey insightWhy it worksCommon pitfallConnection

Unlock answer keys One Family plan — every worked solution, all subjects

Example 2

medium
Linear regression fits y=ax+by = ax + b. If a model with a=2,b=3a=2, b=3 gives predictions y=5,7,9y=5, 7, 9 for x=1,2,3x=1, 2, 3 but observed values are 5,8,105, 8, 10, compute the residuals.

Example 3

medium
A queueing-system model assumes Poisson arrivals at rate λ\lambda and exponential service at rate μ\mu. What single quantity decides whether the queue grows without bound?

Example 4

hard
An epidemic SIR model uses SIS \to I at rate βSI/N\beta SI/N and IRI \to R at rate γI\gamma I. What is the basic reproduction number R0R_0?

Example 5

hard
A traffic-flow model treats roads as a directed weighted graph (edges = travel time). What is one situation where this model badly mis-predicts arrival time?

Example 6

hard
A pricing model uses `cost = base + 0.1 * distance`. A regression on real data finds `cost = 5 + 0.12 * distance - 0.0002 * distance^2`. What does the new quadratic term suggest about the original model?

Example 7

hard
Two models predict next-day stock price: model A uses today's price; model B uses today's price plus volume. Suggest one metric and one risk of comparing them.

Example 8

medium
A chatbot represents a conversation as a list of `{role, content}` messages. What modeling choice does this make about the conversation's structure?

Example 9

challenge
George Box wrote 'all models are wrong, but some are useful.' Give a CS example illustrating each half of the quote.

Example 10

challenge
A neural-net language model has a context window of 8K tokens. State two distinct modeling consequences of this finite window.

Example 11

easy
A savings model uses B=100+20mB = 100 + 20m for month mm. Find BB at m=6m=6 and explain each part of the formula.

Example 12

medium
A model assumes constant 5% monthly growth: Vm=V0×1.05mV_m = V_0 \times 1.05^m. With V0=200V_0 = 200, find V3V_3.

Example 13

medium
A bridge model ignores wind. Predicted maximum load is 10,000 kg. Reality fails at 7,500 kg in a storm. What is wrong with the model and how do you fix it?

Example 14

hard
A model assumes a coin is fair. After 1000 flips you see 580 heads. Is the assumption suspicious?

Example 15

hard
A budget model: C(n)=100+0.5n2C(n) = 100 + 0.5n^2. Compute average cost per item at n=10n=10 and n=20n=20.

Practice Problems

Try these problems on your own first, then open the solution to compare your method.

Example 1

easy
A map of a city leaves out individual trees and house colors but keeps streets and intersections. What modeling principle does this show?

Example 2

easy
A model predicts cost as C=5nC = 5n for nn items. What is the predicted cost for 12 items?

Example 3

easy
A model assumes 'no friction' to predict a sliding box's motion. What part of the model is 'no friction'?

Example 4

easy
A weather model says '70% chance of rain.' Should you treat this as a guaranteed fact?

Example 5

easy
A population model is P=100×2tP = 100 \times 2^t (t in years). What is PP at t=3t = 3?

Example 6

easy
To decide which simplification to keep in a model, what question should guide you?

Example 7

easy
A flight simulator models air resistance but a board game models nothing physical. Why can both be valid models?

Example 8

easy
A model's output is written as f(inputs,assumptions)f(\text{inputs}, \text{assumptions}). If the assumptions are wrong, what happens to the output?

Example 9

medium
A model predicts sales S=20010pS = 200 - 10p where pp is price. Predict sales at p=15p = 15, and state when the model becomes nonsensical.

Example 10

medium
Two models predict tomorrow's temperature: A says 20C, B says 22C. The actual is 21C. How would you compare the models' accuracy?

Example 11

medium
A traffic model assumes all cars travel at exactly the speed limit. Name one consequence and whether the assumption is realistic.

Example 12

medium
A coin-flip game is modeled by random numbers. After 10 simulated games you got 8 heads. Does this mean the model is biased? Explain.

Example 13

medium
A budget model uses cost=fixed+per-unit×n\text{cost} = \text{fixed} + \text{per-unit} \times n. Given fixed =50=50, per-unit =3=3, find cost for n=20n=20 and identify the model's two parameters.

Example 14

medium
A model of a bouncing ball ignores air and assumes each bounce reaches 80% of the prior height. From 10 m, what height after 2 bounces?

Example 15

medium
A spreadsheet model and the real system disagree after a parameter changed. What is the disciplined first step before trusting either?

Example 16

medium
A model of disease spread starts with 1 infected and doubles infections daily. On which day do infections first exceed 1000?

Example 17

challenge
A climate model adds 50 detailed sub-systems and becomes both slower and less accurate than a simpler version. Explain this using a modeling principle.

Example 18

challenge
Two models fit past data perfectly but predict opposite futures. What does this reveal about fitting past data, and what test distinguishes them?

Example 19

challenge
A model assumes events are independent, but in reality one event makes another more likely. Qualitatively, how will the model's risk estimate be biased?

Example 20

medium
A savings model uses balance=1000×1.05t\text{balance} = 1000 \times 1.05^t for tt years at 5% interest. What is the balance after 2 years?

Example 21

easy
A program represents a student as `{ name: 'Alice', grade: 7, gpa: 3.6 }`. Which modeling principle is shown by NOT storing the student's shoe size?

Example 22

easy
A queue at a coffee shop is modeled as a FIFO list. Which CS data structure is the right code representation?

Example 23

easy
A model says cost = 5n+205n + 20 for nn items. What is the predicted cost for 0 items, and what real-world thing does the 2020 probably represent?

Example 24

medium
A library models books with `{ id, title, author, isbn }`. Argue why `author` should likely be a separate `Author` entity with a foreign key.

Example 25

medium
A bird-flock simulation models each bird with 3 simple rules (separation, alignment, cohesion). What kind of model is this?

Example 26

medium
Color is sometimes modeled as 3 values (R, G, B) and sometimes as 4 (R, G, B, A). When is the 4-channel model justified?

Example 27

medium
A chess game is modeled as an 8x8 array of pieces plus 'whose turn'. Name one piece of state this misses that affects legal moves.

Example 28

medium
A movie recommender models a user as a 50-dimensional vector. What does each dimension represent in a typical matrix-factorization model?

Example 29

hard
A 2D physics engine models objects as circles with (x,y,vx,vy)(x, y, vx, vy) and ignores rotation. Name one real-world phenomenon that this model can't reproduce.

Example 30

hard
A finite-state machine models a vending machine with 3 states and 2 inputs (coin, button). What is the input-output property required for it to be deterministic?

Example 31

hard
A markov-chain model uses transition matrix PP with Pij0P_{ij} \ge 0 and jPij=1\sum_j P_{ij} = 1. What invariant does the model enforce on each row?

Example 32

medium
A spam classifier models messages as bags-of-words. What information about word order is lost?

Example 33

medium
A game models physics in discrete steps of Δt=1/60\Delta t = 1/60 s. What artifact appears when an object's speed crosses about 60(object size)60 \cdot \text{(object size)} per second?

Example 34

challenge
Discrete-event simulation vs continuous simulation: when modeling a fast-food drive-through, which is more natural and why?

Example 35

hard
Modeling time: when is a monotonic clock (e.g., `CLOCK_MONOTONIC`) preferred over wall-clock time (`CLOCK_REALTIME`) in code?

Example 36

easy
A subway map shows lines and stations as straight segments but ignores real geography. What modeling principle is at work?

Example 37

easy
A model predicts revenue as R=8nR = 8n for nn tickets. Predict RR for n=25n = 25.

Example 38

easy
A model says next year's class size N=30+2tN = 30 + 2t, with tt in years from now. Find NN at t=4t = 4.

Example 39

easy
A model output disagrees with measured data. According to the formula output=f(inputs,assumptions)\text{output} = f(\text{inputs}, \text{assumptions}), what are the two places to check?

Example 40

easy
A flowchart of how a vending machine works is a kind of model. What does it represent?

Example 41

medium
A model predicts profit as P=5n100P = 5n - 100 where nn is units sold. Find break-even (P=0P=0) and profit at n=80n=80.

Example 42

medium
A drag model says terminal velocity grows with weight. A 1 kg ball measured at 5 m/s; a 4 kg ball measured at 8 m/s. Does the data support 'velocity grows with weight'?

Example 43

medium
A traffic model treats every car as identical. Name one consequence for predicting congestion at a mixed truck/car highway.

Example 44

medium
A pizza-shop model: cost =200+4n= 200 + 4n (in dollars) for nn pizzas; revenue =12n= 12n. Find the break-even nn.

Example 45

medium
A model gives daily temperatures: 18, 20, 22, 21, 19. The actuals were 19, 19, 23, 22, 18. What is the mean absolute error?

Example 46

medium
A queueing model assumes customers arrive once per minute and each is served in 30 seconds. Will the queue grow over time?

Example 47

medium
A model says taxi fare =3+2d= 3 + 2d dollars for distance dd km. A passenger pays $13. Find dd.

Example 48

medium
A model assumes growth follows N=50×1.1tN = 50 \times 1.1^t. After how many whole years does NN first exceed 100?

Example 49

medium
A growth model uses doubling every 3 days. Starting at 4, what is the count after 12 days?

Example 50

hard
A model predicts cost C(n)=0.05n2+2n+50C(n) = 0.05 n^2 + 2n + 50 dollars to produce nn items. Find C(10)C(10) and C(20)C(20), then say how cost per item changes.

Example 51

hard
A model predicts that doubling staff cuts wait time in half. Real test: 4 staff -> 20 min, 8 staff -> 16 min. Comment on the model.

Example 52

hard
A predator-prey model assumes prey grows unlimited without predators. Why is this assumption only usable in the short term?

Example 53

hard
A flight model gives fuel use F=0.02d+50F = 0.02 d + 50 liters for dd km. Real fuel use for a 500 km flight was 80 liters. By how much is the model off, and is it under- or over-predicting?

Example 54

challenge
A disease model assumes everyone mixes equally. Real societies form clusters. Will the model over- or underestimate the speed of an outbreak in a clustered network with the same average contacts?

Example 55

challenge
A linear model with two unknown parameters is fit to 100 points. Why is fitting still possible even with noisy data?

Background Knowledge

These ideas may be useful before you work through the harder examples.

abstractionsimulation