<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
linear	B-Algorithm
search	I-Algorithm
or	O
sequential	B-Algorithm
search	I-Algorithm
is	O
a	O
method	O
for	O
finding	O
an	O
element	O
within	O
a	O
list	O
.	O
</s>
<s>
A	O
linear	B-Algorithm
search	I-Algorithm
runs	O
in	O
at	O
worst	O
linear	O
time	O
and	O
makes	O
at	O
most	O
comparisons	O
,	O
where	O
is	O
the	O
length	O
of	O
the	O
list	O
.	O
</s>
<s>
If	O
each	O
element	O
is	O
equally	O
likely	O
to	O
be	O
searched	O
,	O
then	O
linear	B-Algorithm
search	I-Algorithm
has	O
an	O
average	O
case	O
of	O
comparisons	O
,	O
but	O
the	O
average	O
case	O
can	O
be	O
affected	O
if	O
the	O
search	O
probabilities	O
for	O
each	O
element	O
vary	O
.	O
</s>
<s>
Linear	B-Algorithm
search	I-Algorithm
is	O
rarely	O
practical	O
because	O
other	O
search	B-Application
algorithms	I-Application
and	O
schemes	O
,	O
such	O
as	O
the	O
binary	O
search	B-Application
algorithm	I-Application
and	O
hash	B-Algorithm
tables	I-Algorithm
,	O
allow	O
significantly	O
faster	O
searching	O
for	O
all	O
but	O
short	O
lists	O
.	O
</s>
<s>
A	O
linear	B-Algorithm
search	I-Algorithm
sequentially	O
checks	O
each	O
element	O
of	O
the	O
list	O
until	O
it	O
finds	O
an	O
element	O
that	O
matches	O
the	O
target	O
value	O
.	O
</s>
<s>
Given	O
a	O
list	O
of	O
elements	O
with	O
values	O
or	O
records	O
,	O
and	O
target	O
value	O
,	O
the	O
following	O
subroutine	O
uses	O
linear	B-Algorithm
search	I-Algorithm
to	O
find	O
the	O
index	O
of	O
the	O
target	O
in	O
.	O
</s>
<s>
By	O
adding	O
an	O
extra	O
record	O
to	O
the	O
list	O
(	O
a	O
sentinel	B-Data_Structure
value	I-Data_Structure
)	O
that	O
equals	O
the	O
target	O
,	O
the	O
second	O
comparison	O
can	O
be	O
eliminated	O
until	O
the	O
end	O
of	O
the	O
search	O
,	O
making	O
the	O
algorithm	O
faster	O
.	O
</s>
<s>
Either	O
way	O
,	O
asymptotically	O
the	O
worst-case	O
cost	O
and	O
the	O
expected	O
cost	O
of	O
linear	B-Algorithm
search	I-Algorithm
are	O
both	O
O(n )	O
.	O
</s>
<s>
The	O
performance	O
of	O
linear	B-Algorithm
search	I-Algorithm
improves	O
if	O
the	O
desired	O
value	O
is	O
more	O
likely	O
to	O
be	O
near	O
the	O
beginning	O
of	O
the	O
list	O
than	O
to	O
its	O
end	O
.	O
</s>
<s>
In	O
particular	O
,	O
when	O
the	O
list	O
items	O
are	O
arranged	O
in	O
order	O
of	O
decreasing	O
probability	O
,	O
and	O
these	O
probabilities	O
are	O
geometrically	O
distributed	O
,	O
the	O
cost	O
of	O
linear	B-Algorithm
search	I-Algorithm
is	O
only	O
O(1 )	O
.	O
</s>
<s>
Linear	B-Algorithm
search	I-Algorithm
is	O
usually	O
very	O
simple	O
to	O
implement	O
,	O
and	O
is	O
practical	O
when	O
the	O
list	O
has	O
only	O
a	O
few	O
elements	O
,	O
or	O
when	O
performing	O
a	O
single	O
search	O
in	O
an	O
un-ordered	O
list	O
.	O
</s>
<s>
For	O
example	O
,	O
one	O
may	O
sort	B-Algorithm
the	O
list	O
and	O
use	O
binary	O
search	O
,	O
or	O
build	O
an	O
efficient	O
search	B-Data_Structure
data	I-Data_Structure
structure	I-Data_Structure
from	O
it	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
even	O
though	O
in	O
theory	O
other	O
search	B-Application
algorithms	I-Application
may	O
be	O
faster	O
than	O
linear	B-Algorithm
search	I-Algorithm
(	O
for	O
instance	O
binary	O
search	O
)	O
,	O
in	O
practice	O
even	O
on	O
medium-sized	O
arrays	O
(	O
around	O
100	O
items	O
or	O
less	O
)	O
it	O
might	O
be	O
infeasible	O
to	O
use	O
anything	O
else	O
.	O
</s>
<s>
On	O
larger	O
arrays	O
,	O
it	O
only	O
makes	O
sense	O
to	O
use	O
other	O
,	O
faster	O
search	O
methods	O
if	O
the	O
data	O
is	O
large	O
enough	O
,	O
because	O
the	O
initial	O
time	O
to	O
prepare	O
(	O
sort	B-Algorithm
)	O
the	O
data	O
is	O
comparable	O
to	O
many	O
linear	B-Algorithm
searches	I-Algorithm
.	O
</s>
