Mathematics I / Computational Complexity
Practice question · Multiple choice

An O(n²) algorithm can beat an O(n log n) one on real data. Why does big-O notation not settle which program to use?

Hints
  1. Compare 100·n log n against 2·n² at n = 10. Which is larger?
  2. Ask what big-O deliberately throws away.
Show the answer

D. Because big-O describes growth and discards constant factors.

Why

Big-O discards constants and lower-order terms to answer one question cleanly, and those discarded parts decide small cases: at n = 10, 100·n log n is about 3300 units against 2n²'s 200. Production sorts are hybrids for exactly this reason, switching to insertion sort below 10 to 20 elements. The mistake is treating an answer about growth as an answer about speed.

Read the lesson: Computational Complexity →

Practise Computational Complexity

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

More questions on Computational Complexity