成人快手

Selection 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 selection?

An explanation of selection, as used in algorithms and programming

Selection is a decision or question.

At some point in an algorithm there may need to be a question because the algorithm has reached a step where one or more options are available. Depending on the answer given, the algorithm will follow certain steps and ignore others.

Selection is making a decision on which logical path to follow. In a theme park, the queuing system for a roller coaster might read 'IF front row, queue here, else, all other rows queue here'.

Why is selection important?

Without selection, different paths would not be included in algorithms. This means that the solutions created would not be realistic.