Iteration In Algorithms - KS3 Computer Science Revision - BBC

In this guide

  1. Revise
  2. Test
  1. Iteration in algorithms
  2. Iteration in practice: Cleaning teeth
  3. Conditions and counters
  4. Representing iteration

Iteration in algorithms

An algorithm is a plan, a set of step-by-step instructions to solve a problem. There are three basic building blocks (constructs) to use when designing algorithms:

  • sequencing
  • selection
  • iteration

These building blocks help to describe solutions in a form ready for programming.

What is iteration?

An explanation of iteration, as used in algorithms and programming

Open Transcript

Iteration in programming means repeating steps, or instructions, over and over again. This is often called a ‘loop’.

Iteration is the repetition of a sequence. In an arcade game, the sequence is Pop up a new rat, hit the rat increase score. This will continue to iterate as the game is being played.
Figure caption, An example of iteration

Algorithms consist of instructions that are carried out (performed) one after another. Sometimes an algorithm needs to repeat certain steps until told to stop or until a particular condition has been met.

Key factIteration is the process of repeating steps.

For example, a very simple algorithm for eating breakfast cereal might consist of these steps:

  • put cereal in bowl
  • add milk to cereal
  • spoon cereal and milk into mouth
  • repeat step 3 until all cereal and milk is eaten
  • rinse bowl and spoon

Why is iteration important?

Iteration allows algorithms to be simplified by stating that certain steps will repeat until told otherwise. This makes designing algorithms quicker and simpler because they don’t need to include lots of unnecessary steps.

Next pageIteration in practice: Cleaning teeth

More guides on this topic

  • Designing an algorithm
  • Searching
  • Sorting
  • Sequencing
  • Selection
  • Logical reasoning

Related links

  • Jobs that use Computer Science
  • BBC Click
  • BBC Technology news
  • Tech Tent
  • Headsqueeze
  • Khan Academy
  • Raspberry Pi
  • Code Club Subscription
  • Educational App Store Subscription

Tag » What Is Iteration In Computer Science