Free practice · single-choice · medium

Practice

Trace a sentinel stop

A loop reads [5, 7, -1, 9], adds values until it sees sentinel -1, and stops before adding the sentinel. What total is produced?

Repeated-state trace

A loop must make visible progress toward a defined stop

  1. InitializeSet deliberate starting state
  2. ReadTake the next item or state
  3. DecideEvaluate the loop condition
  4. UpdateChange counters and accumulators
  5. RecordWrite the reached state
  6. StopConfirm the stopping rule

Record the item, condition, counter, accumulator, and stopping decision on every pass to expose skipped, duplicated, or non-terminating work.

Choose one answer