Algorithm CS Thinking Example 1

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

Example 1

easy
Write an algorithm (as numbered steps) for making a cup of tea.

Solution

  1. 1
    Step 1: Identify the key actions in order โ€” boil water, prepare the cup, brew, and serve.
  2. 2
    Step 2: Write clear, unambiguous steps: 1. Fill kettle with water. 2. Boil the kettle. 3. Place tea bag in cup. 4. Pour boiling water into cup. 5. Wait 3 minutes. 6. Remove tea bag. 7. Add milk if desired.
  3. 3
    Step 3: Verify the algorithm is complete (handles start to finish) and each step is precise enough for anyone to follow.

Answer

A 7-step algorithm from filling the kettle to adding milk, with each instruction clear and ordered.
An algorithm is a step-by-step set of instructions to solve a problem or complete a task. Good algorithms are precise, unambiguous, and finite.

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