Computer Science I / What Makes an Algorithm Good
Practice question · Sort into groups

A set of instructions counts as a genuine algorithm only if it is finite (it always stops) and definite (every step is unambiguous). Sort each description.

Groups: Is a valid algorithm · Not an algorithm

Hints
  1. Test each one against two demands: does it terminate, and is every step precise?
  2. A step that says 'somehow' or 'until it feels right' fails definiteness; a loop with no exit fails finiteness.
Show the answer

Is a valid algorithm: For each item in the list, swap it with its neighbour if larger, then stop, Double x, then subtract 3, then halt

Not an algorithm: Keep guessing a number until it feels right, Repeat 'add 1 to x' forever

Why

A valid algorithm must be finite and definite. 'Guess until it feels right' and 'do something clever' are not definite, and 'repeat forever' is not finite. The others give an exact, terminating recipe.

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