大象传媒

Algorithms - EdexcelThe three basic programming constructs

Algorithms are step-by-step plans for solving problems. Algorithms can be designed using pseudo-code, flowcharts, written descriptions and program code. There are also some standard algorithms for searching and sorting.

Part of Computer SciencePrinciples of computer science

The three basic programming constructs

are designed using common building blocks. These building blocks, known as programming constructs, form the basis for all programs.

There are three basic building blocks to consider:

Sequence is the order in which occur and are processed. Selection determines which path a program takes when it is running. Iteration is the repeated execution of a section of code when a program is running.

There are two types of iteration:

  • count-controlled iteration
  • condition-controlled iteration

All programs use one or more of these constructs. The longer and more complex the program, the more these constructs will be used repeatedly.

This guide uses examples to illustrate the constructs. It is important to realise that while all include these constructs, there may be slightly different formats.