成人快手

SequencingRepresenting sequencing

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

Representing sequencing

There are two ways of representing :

  • a flow chart (also known as a flow diagram)

Representing sequencing in pseudocode

Writing in pseudocode is rather like writing in a . Each step of the algorithm is written on a line of its own, in sequence.

Consider this simple algorithm for calculating how old a dog is in dog years. It contains three steps, all in sequence:

  • ask how old the dog is in human years
  • multiply human years by seven to find out how old the dog is in dog years
  • print the answer on the screen

In pseudocode, the algorithm would look like this:

OUTPUT 'How old is your dog?'
INPUT user inputs their dog's age in human years
STORE the user's input in the human_years variable
dog_years = human_years * 7
OUTPUT 'In dog years, your dog is aged' + dog_years

Representing sequencing in a flow chart

A flowchart asking for a dogs age will first ask for your dogs age and then based on the calculation that one human year is 7 dog years, work out how old your dog is in dog years.