Curriculum

Curriculum

Find the Missing Step in a Sequence

Scenario

A campus library checkout kiosk checks whether a book has copies left and hands it to a student, but a technician compares two versions of the kiosk flowchart: Version A forgets to decrease availableCopies after checkout, while Version B updates availableCopies before finishing.

Selected choicePick a choice below
Result—

Try it yourself

If 1 copy of a book remains and two students check it out one after another using Version A, what will the second student see?

Reveal the explanation
  1. availableCopies = 3; Version A (no update) vs Version B (update -1) after 1 checkout

    Version A still shows 3; Version B shows 2

  2. availableCopies = 1; two back-to-back checkouts on Version A vs Version B

    Version A approves both (invalid double checkout); Version B approves first (0 left) and blocks second

  3. availableCopies not read before checking availableCopies > 0 (uses stale cached 2 when shelf has 0); Version B reads current count first

    Version A tries to lend a missing book; Version B reads 0 and stops

To audit any sequence, trace each piece of data from start to finish: confirm it is read fresh before being tested, and confirm every completed action writes its updated value back before the sequence ends.

Download shared test cases

Your turn

Compare a 4-step study-room booking sequence (1. Read roomStatus, 2. Confirm roomStatus is free, 3. Print ticket, 4. End) against what happens when two students book the same room, and write down the exact missing step and where it belongs.

Common mistake Adding a second check instead of adding the missing state update (writing roomStatus = booked).

Check your work

Identify Step 3.5 as 'Set roomStatus = booked' placed immediately before printing the ticket or ending the sequence.

Quick check

A classroom quiz app scores an answer as correct, displays '+1 point', and finishes, but totalScore never increases on the summary screen. Which step is missing?
Show the answer and reasoning

Correct answer Updating totalScore = totalScore + 1 before finishing

Displaying a message only informs the user; without updating totalScore, the stored total stays unchanged.