Selection
An algorithmA sequence of logical instructions for carrying out a task. In computing, algorithms are needed to design computer programs. is a plan, a set of step-by-step instructionA single action that can be performed by a computer processor. designed to solve a problem. When designing algorithms there are three basic building blocks (constructs) that can be used:
- sequencingCreating a set of instructions to complete a task.
- selectionA decision within a computer program when the program decides to move on based on the results of an event.
- iterationIn computer programming, this is a single pass through a set of instructions.
Algorithms are used to help design programSequences of instructions for a computer. that perform particular tasks.
What is selection?
Selection is a decision or question.
At some point, a program may need to ask a question because it has reached a step where one or more options are available. Depending on the answer given, the program will follow a certain step and ignore the others.
Why is selection important?
Many solutions feature several choices or decisions. These decisions lead to different paths through the program. These paths represent the result of making a choice. Without selection it would not be possible to include different paths in programs, and the solutions we create would not be realistic.
Selection in programming
Once an algorithm has been designed and perfected, it must be translated 鈥 or programmingThe process of writing computer software. 鈥 into code that a computer can read.
We create programs to implementTo put into effect. algorithms. Algorithms consist of steps, where programs consist of statementThe smallest element of a programming language which expresses an action to be carried out..
Selection is implemented in programming using IF statements.