Mathematics I / Algorithms and Computational Thinking
Practice question · Multiple choice

A specification says WHAT the answer must be; an algorithm says HOW to get it. Why is the distinction worth maintaining, when a correct algorithm satisfies its specification anyway?

Hints
  1. Name two different ways to find the largest element of a list. Do they satisfy the same specification?
  2. Ask what question is left open once you know the answer is correct.
Show the answer

A. Because one specification admits many algorithms of different cost.

Why

'Return the largest element' is satisfied by a single pass in n steps, by sorting in n log n, and by comparing every pair in n², all correct, and the specification cannot tell them apart. So correctness is the floor and choosing among the correct options is the design work. It also makes improvement safe, which is the same insight the abstract data type lesson makes about interfaces.

Read the lesson: Algorithms and Computational Thinking →

Practise Algorithms and Computational Thinking

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

More questions on Algorithms and Computational Thinking