14D. Summary

A search algorithm scans a sequence once looking for a value with some desired property.

Suppose that A is an array of size n. A boilerplate algorithm to search array A is as follows.

  for(int i = 0; i < n; i++)
  {
    if(A[i] has the desired property)
    {
      break or return (as appropriate): the value has been found
    }
  }
  There is no value in array A with the desired property

Notice that the if-statement has no else part. If A[i] does not have the desired property, the algorithm tries the next value of i.