Physics I / Complexity and efficiency basics
Practice question · Estimate

An O(n2)O(n^{2}) simulation takes 2 seconds for n=1000n = 1000 particles. Predict its runtime for n=5000n = 5000, in seconds.

Estimate on a scale from 0 s (0) to 100 s (100).

Hints
  1. Quadratic work scales with the square of the size ratio.
  2. 5× the particles → 52=25×5^{2} = 25\times the time.
Show the answer

50 (answers within ±5 count)

Why

2×25=502 \times 25 = 50 s. Extrapolating by growth class is a superpower: before buying hardware, you know 50,000 particles would take ~83 minutes, and that an O(nlogn)O(n\log n) algorithm is worth finding.

Read the lesson: Complexity and efficiency basics →

Practise Complexity and efficiency basics

The app has 8 more questions on this lesson, and keeps your place in the course. Physics I is free to start.

More questions on Complexity and efficiency basics