1 of 9

Stress Testing

03/07/2024

2 of 9

What is Stress Testing?

  • Allows you to compare outputs between two programs
  • Find differences between outputs to get failing test cases

3 of 9

Why Stress Test?

  • In contest - Find counter cases for a fast but incorrect solution (ex. greedy)
  • Understanding why your solution is wrong, stress test against correct solution

4 of 9

How to Stress Test?

Generator

Main Solution

Slow Solution

Input

Output 1

Output 2

Compare

5 of 9

Example

  • You can write a script for stress testing or use a package
  • We’ll stress test by using a package called “qstress”

6 of 9

Example Problem

Given an array, find how many subarrays have a sum of 0

Ex: [3, -2, 2, -2] => 2

7 of 9

Example Solutions

  • O(n2) - Iterate over all subarrays and count number with sum 0
  • O(n) / O(n log n) - Maintain the prefix sums, adding to the total answer the number of prefix subarrays with the same prefix sum

8 of 9

ProCo II - 2024

  • Register here!

9 of 9

Member Presentations!

– Great for officer apps, allow us to see how you present

– Present on any CS related topic!

https://forms.gle/m7ie56Nq15yqaH4y6