Mathematics I / Algorithms and Computational Thinking
Practice question · Sort into groups

An algorithm says HOW to compute; a specification says only WHAT the answer is. Sort each item.

Groups: Algorithm · Specification only

Hints
  1. Ask of each item: could a machine follow this and halt with an answer?
  2. A perfectly precise description of the answer can still tell you nothing about producing it.
Show the answer

Algorithm: Replace (a, b) by (b, a mod b) until b is 0, then report a, Test each of 2, 3, ..., n-1 as a divisor of n; if none divides, report n prime, Scan the list keeping the largest value seen so far, then report it

Specification only: The gcd of a and b is their largest common divisor, The prime factorisation is the unique product of primes equal to n

Why

a1, a3 and a5 give concrete terminating procedures. a2 and a4 characterise the answer without saying how to find it, the classic confusion of this lesson. A definition becomes an algorithm only when it is turned into steps.

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