Computer Science I / Complexity and Performance Trade-offs
Practice question · Multiple choice

A team spends a week optimising a function that accounts for 2% of runtime. What did they get, and what is the rule they violated?

Hints
  1. If a part is 2% of the total and you make it infinitely fast, what happens to the total?
  2. Ask what they should have done in the first hour.
Show the answer

D. At most a 2% improvement, since the other 98% dominates

Why

Making 2% of the runtime instantaneous saves 2%, so the ceiling was set before they started. Profiling first is the discipline, and the reason it matters is that developers guess hot spots badly, which is why 'measure, don't guess' outranks any particular optimisation technique.

Read the lesson: Complexity and Performance Trade-offs →

Practise Complexity and Performance Trade-offs

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 and Performance Trade-offs