Concept:Linear search
== Headline ==
Solve the [[search problem]] by iterating over the input list
== Description ==
Consider the [[search problem]], i.e., the problem of determining whether a given value occurs in a given list. This problem is an [[algorithmic
problem]], i.e., it can be solved by an [[algorithm]], e.g., by linear search.
Semi-formally, linear search can be described by an algorithm as follows:
* Given is a list ''l'' and a value ''v'' of the element type of ''l''.
* Perform the following steps to search ''v'' in ''l'':
** Initialize an index variable ''i'' to 0 (to refer to the first element of ''l'', if any).
** Repeat the following steps until a result is returned.
*** Return ''False'', if ''i'' equals the length of ''l''.
*** Return ''True'', if ''l'' stores ''v'' at the index ''i''.
*** Increment ''i''.
Please note that this formulation also expresses that the element type must admit comparison for equality.
== Illustration ==