成人快手

SequencingSequencing in algorithms

When designing algorithms, it is important to make sure that all the steps are presented in the correct order. This is known as sequencing, and can be displayed in pseudocode or flowcharts.

Part of Computer ScienceAlgorithms

Sequencing in algorithms

An 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 .

What is sequencing?

An explanation of sequencing, as used in algorithms and programming

Algorithms consist of instructions that are carried out (performed) one after another.

Sequencing means putting and executing instructions in order. An example is a fast food drive through when the procedure is order, pay, collect.

For example, a very simple algorithm for brushing teeth might consist of these steps:

  1. put toothpaste on toothbrush
  2. use toothbrush to clean teeth
  3. rinse toothbrush

Each step is an instruction to be performed. Sequencing is the order in which the steps are carried out.

Why is sequencing important?

It is crucial that the steps in an algorithm are performed in the right order - otherwise the algorithm will not work correctly. Suppose the steps for the teeth-cleaning algorithm were in this sequence:

  1. use toothbrush to clean teeth
  2. put toothpaste on toothbrush
  3. rinse toothbrush

A toothbrush would still be used to clean the teeth and toothpaste would still be put on the brush. But because steps 1 and 2 are in the wrong sequence the teeth wouldn鈥檛 get cleaned with the toothpaste, and the toothpaste would be wasted.

A human would realise they had forgotten to add toothpaste at the start of the process, but a computer would not know that anything was wrong.

A computer can only do what it is programmed to do. If the steps are programmed in the wrong sequence, the computer will perform the tasks in this sequence 鈥 even if this is incorrect.