Computer Science I / What Makes an Algorithm Good
Practice question · Put in order

Order the recommended design workflow, which puts correctness before speed.

Hints
  1. The pitfall warns against doing the last step too early.
  2. You cannot sensibly optimize something you have not yet shown to be correct.
Show the answer
  1. Work out precisely what the correct output is for every input
  2. Write an algorithm and argue why it is correct
  3. Measure how its cost grows with input size
  4. Only then rewrite it to run faster
Why

Establish what is correct, build and justify a correct method, analyze its cost, and optimize last. Optimizing before correctness is the named pitfall.

Read the lesson: What Makes an Algorithm Good →

Practise What Makes an Algorithm Good

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 What Makes an Algorithm Good