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

An algorithm to get a computer to draw a square on the screen might consist of these steps:

- draw a 3 cm line
- turn left 90 degrees
- draw a 3 cm line
- turn left 90 degrees
- draw a 3 cm line
- turn left 90 degrees
- draw a 3 cm line

The steps in this algorithm are in the correct sequence. This algorithm would result in a perfect square:

If there was a mistake when designing the algorithm, and the steps in this sequence were placed like this:

- draw a 3 cm line
- turn left 90 degrees
- draw a 3 cm line
- turn left 90 degrees
- draw a 3 cm line
- draw a 3 cm line
- turn left 90 degrees

This algorithm would create this shape, rather than a perfect square:

Because step 6 is in the wrong sequence (it should switch with step 7), this algorithm failed. However, fixing the algorithm - and the square - is easy, because there are only seven steps to look through for the error.

Complex algorithms may have hundreds, if not thousands, of steps. It is critical to make sure all steps in the algorithm are in the correct sequence before programming begins. Once programmed, trying to find an instruction in the wrong sequence can be extremely difficult.