Computer Science I / Complexity Analysis
Practice question · Put in order

Order these complexity classes from slowest-growing to fastest-growing.

Hints
  1. Constant grows slowest; a squared term grows fastest here.
  2. Logarithmic beats linear, which beats linearithmic, which beats quadratic.
Show the answer
  1. O(1)
  2. O(log n)
  3. O(n)
  4. O(n log n)
  5. O(n^2)
Why

From slowest to fastest growth: O(1), O(log n), O(n), O(n log n), O(n^2). Knowing this ordering is what lets you compare algorithms at a glance.

Read the lesson: Complexity Analysis →

Practise Complexity Analysis

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

More questions on Complexity Analysis