 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
The
most obvious and primitive way to search for
|
|
|
a
given key is to start at the beginning of the list
|
|
|
of
data items and look at each item in sequence.
|
|
|
| • |
This
is called a sequential or linear search.
|
|
|
| • |
The
sequential search quits as soon as it finds a
|
|
|
copy
of the search key in the array. If we are very
|
|
|
lucky,
the very first key examined may be the one
|
|
we
are looking for. This is the best possible case.
|
|
|
| • |
In
the worst case, the algorithm may search the
|
|
|
entire
search area - from the first to the last key
|
|
|
before
finding the search value in the last element
|
|
|
-- or
finding that it isn't present at all.
|
|