Algorithm CS Thinking Example 4

Follow the full solution, then compare it with the other examples linked below.

Example 4

easy
A recipe says, 'Add sugar until it tastes right.' Explain why this is a poor algorithm step and rewrite it so it is precise.

Solution

  1. 1
    Step 1: The instruction is vague because different people may disagree about when it 'tastes right'. An algorithm needs steps that are clear and unambiguous.
  2. 2
    Step 2: Rewrite it with a measurable action, such as 'Add 2 teaspoons of sugar and stir for 10 seconds.'

Answer

It is too vague to be an algorithm step. A precise version is: 'Add 2 teaspoons of sugar and stir for 10 seconds.'
Algorithms must be precise enough that anyone following the steps would do the same thing. Subjective instructions introduce ambiguity and make the result unreliable.

About Algorithm

A step-by-step set of instructions for solving a problem or accomplishing a specific task. An algorithm must be precise (every step is unambiguous), finite (it terminates after a bounded number of steps), and effective (each step can actually be carried out).

Learn more about Algorithm โ†’

More Algorithm Examples