Linear search

A search is a method for finding an item of data.

The simplest type of search is a linear search (serial or sequential search), which basically starts at the beginning of a file, reading each record until the required record is found.

Not an efficient method of searching but if the data is not sorted, this is the only method of searching.

Pseudocode:

Assume an array of strings Key[n]. The string to be searched for and processed is SearchKey

input(SearchKey)
n = 0
repeat
  if key[n] = SearchKey then
      process SearchKey
  end if
  n = n + 1
Until key[n-1] = SearchKey