Computer Science I / Complexity Analysis
Practice question · Multiple choice

Best case, average case and worst case give three different answers for the same algorithm. Which one should a system be designed around, and why?

Hints
  1. Ask what happens if one operation takes a thousand times longer than usual, in a web server and in a pacemaker.
  2. Is the answer the same for both systems?
Show the answer

B. It depends on the consequence of being slow.

Why

The right case depends on what a slow operation costs: a web server absorbs an occasional slow request, and a real-time system that misses a deadline has missed it. Which is why quicksort is a fine default and a poor real-time choice. The worst case is also an attack surface, hash flooding triggers it deliberately, and 'it never happens in practice' holds only while nobody is trying.

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