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
- Name two different ways to find the largest element of a list. Do they satisfy the same specification?
- 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.
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
- Order the steps of the algorithm that finds the largest value in a list.
- A recipe is a precise sequence of steps and is not an algorithm in the strict sense. Which requirement does…
- Select every procedure below that FAILS to be a genuine algorithm.
- An algorithm says HOW to compute; a specification says only WHAT the answer is. Sort each item.