Next: Programming paradigms Up: Unit 01 Previous: Class diagram

## Realization of operations: algorithms

Usually, we realize an operation when we need to solve a specific problem.

Example: given a person name, find the corresponding telephone number in a telephone registry.

To delegate to a computer the solution of a problem, it is necessary to find an algorithm that solves the problem.

Algorithm: procedure through which we obtain the solution of a problem. In other words, a sequence of statements that, when executed one after the other, allow one to calculate the solution of the problem starting from the information provided as input.

An algorithm is characterized by:

• non ambiguity: the statements must be interpretable in a unique way by whom is executing them
• executability: it must be possible to execute each statement (in a finite amount of time) given the available resources
• finiteness: the execution of the algorithm must terminate in a finite amount of time for each possible set of input data

Example of an algorithm: scan the person names, one after the other as they appear in the registry, until you have found the requested one; return the associated telephone number.

Are there other algorithms to solve the same problem? Yes!

Once we have found/developed an algorithm, we have to code it in the selected programming language.

Next: Programming paradigms Up: Unit 01 Previous: Class diagram