Name the hypothesis and the safeguard

A student's sorting function returns a list in which one value appears twice and another value is missing. Before editing anything, the student writes: "The swap overwrites a[j] before saving it, so if I print the list right after the first swap I will see two copies of the same value." A testable explanation like this, written down together with the observation it predicts, is called a .


After fixing the swap with a temporary variable, the student saves the original failing list and its expected sorted output as an automated test that runs on every future change, so the same bug cannot quietly return. A test kept for this purpose is called a test.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Debugging Strategies Questions: