Physics I / Complexity and efficiency basics
Practice question · Multiple choice

An O(n2)O(n^2) algorithm can beat an O(nlogn)O(n\log n) one on real data. How is that consistent with the complexity classes?

Hints
  1. Ask what big-O deliberately throws away.
  2. Compare 100nlogn100n\log n with n2n^2 at n=10n = 10.
Show the answer

B. Because big-O describes growth and discards constants

Why

Asymptotic notation is about the limit, and real inputs are finite. Timsort and introsort both exploit this by switching algorithms below a size threshold.

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