Evaluating Solutions to Maximum Pairwise Product Problem

Stress testing

We’ll now introduce stress testing—a technique for generating thousands of tests to find a test case for which our solution fails.

A stress test consists of four parts:

  • Implementation of an algorithm.
  • An alternative, trivial, and slow but correct implementation of an algorithm for the same problem.
  • A random test generator.
  • An infinite loop in which a new test is generated and fed into both implementations to compare the results. If their results differ, the test and both answers are output, and the program stops. Otherwise, the loop repeats.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.