Computer Science I / Complexity Analysis
Practice question · Multiple choice

Two algorithms are both O(n). One runs in 3n operations, the other in 3000n. Big-O calls them identical. Is the notation failing?

Hints
  1. Ask what a constant factor depends on, and whether it is stable across machines.
  2. Both algorithms double their work when n doubles. What question is that answering?
Show the answer

D. No, constants are discarded because they depend on the machine

Why

The discard is deliberate: constants shift with hardware, compiler and cache while the growth rate does not, so big-O captures the portable part. It answers 'what happens as the input grows' and never claimed to answer 'which is faster today', that question is settled by measurement.

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