<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
search	B-Data_Structure
data	I-Data_Structure
structure	I-Data_Structure
is	O
any	O
data	B-General_Concept
structure	I-General_Concept
that	O
allows	O
the	O
efficient	O
retrieval	O
of	O
specific	O
items	O
from	O
a	O
set	O
of	O
items	O
,	O
such	O
as	O
a	O
specific	O
record	O
from	O
a	O
database	O
.	O
</s>
<s>
Locating	O
the	O
desired	O
item	O
in	O
such	O
a	O
list	O
,	O
by	O
the	O
linear	B-Algorithm
search	I-Algorithm
method	O
,	O
inevitably	O
requires	O
a	O
number	O
of	O
operations	O
proportional	O
to	O
the	O
number	O
n	O
of	O
items	O
,	O
in	O
the	O
worst	B-General_Concept
case	I-General_Concept
as	O
well	O
as	O
in	O
the	O
average	O
case	O
.	O
</s>
<s>
Useful	O
search	B-Data_Structure
data	I-Data_Structure
structures	I-Data_Structure
allow	O
faster	O
retrieval	O
;	O
however	O
,	O
they	O
are	O
limited	O
to	O
queries	B-Library
of	O
some	O
specific	O
kind	O
.	O
</s>
<s>
Moreover	O
,	O
since	O
the	O
cost	O
of	O
building	O
such	O
structures	O
is	O
at	O
least	O
proportional	O
to	O
n	O
,	O
they	O
only	O
pay	O
off	O
if	O
several	O
queries	B-Library
are	O
to	O
be	O
performed	O
on	O
the	O
same	O
database	O
(	O
or	O
on	O
a	O
database	O
that	O
changes	O
little	O
between	O
queries	B-Library
)	O
.	O
</s>
<s>
Static	O
search	O
structures	O
are	O
designed	O
for	O
answering	O
many	O
queries	B-Library
on	O
a	O
fixed	O
database	O
;	O
dynamic	O
structures	O
also	O
allow	O
insertion	O
,	O
deletion	O
,	O
or	O
modification	O
of	O
items	O
between	O
successive	O
queries	B-Library
.	O
</s>
<s>
The	O
simplest	O
kind	O
of	O
query	B-Library
is	O
to	O
locate	O
a	O
record	O
that	O
has	O
a	O
specific	O
field	O
(	O
the	O
key	O
)	O
equal	O
to	O
a	O
specified	O
value	O
v	O
.	O
Other	O
common	O
kinds	O
of	O
query	B-Library
are	O
"	O
find	O
the	O
item	O
with	O
smallest	O
(	O
or	O
largest	O
)	O
key	O
value	O
"	O
,	O
"	O
find	O
the	O
item	O
with	O
largest	O
key	O
value	O
not	O
exceeding	O
v	O
"	O
,	O
"	O
find	O
all	O
items	O
with	O
key	O
values	O
between	O
specified	O
bounds	O
vmin	O
and	O
vmax	O
"	O
.	O
</s>
<s>
In	O
that	O
case	O
,	O
common	O
kinds	O
of	O
queries	B-Library
are	O
"	O
find	O
the	O
record	O
with	O
a	O
key	O
closest	O
to	O
a	O
given	O
point	O
v	O
"	O
,	O
or	O
"	O
find	O
all	O
items	O
whose	O
key	O
lies	O
at	O
a	O
given	O
distance	O
from	O
v	O
"	O
,	O
or	O
"	O
find	O
all	O
items	O
within	O
a	O
specified	O
region	O
R	O
of	O
the	O
space	O
"	O
.	O
</s>
<s>
A	O
common	O
special	O
case	O
of	O
the	O
latter	O
are	O
simultaneous	O
range	O
queries	B-Library
on	O
two	O
or	O
more	O
simple	O
keys	O
,	O
such	O
as	O
"	O
find	O
all	O
employee	O
records	O
with	O
salary	O
between	O
50,000	O
and	O
100,000	O
and	O
hired	O
between	O
1995	O
and	O
2007	O
"	O
.	O
</s>
<s>
Array	B-Data_Structure
if	O
the	O
key	O
values	O
span	O
a	O
moderately	O
compact	O
interval	O
.	O
</s>
<s>
Note	O
:	O
Insert	O
on	O
an	O
unsorted	O
array	B-Data_Structure
is	O
sometimes	O
quoted	O
as	O
being	O
O(n )	O
due	O
to	O
the	O
assumption	O
that	O
the	O
element	O
to	O
be	O
inserted	O
must	O
be	O
inserted	O
at	O
one	O
particular	O
location	O
of	O
the	O
array	B-Data_Structure
,	O
which	O
would	O
require	O
shifting	O
all	O
the	O
subsequent	O
elements	O
by	O
one	O
position	O
.	O
</s>
<s>
However	O
,	O
in	O
a	O
classic	O
array	B-Data_Structure
,	O
the	O
array	B-Data_Structure
is	O
used	O
to	O
store	O
arbitrary	O
unsorted	O
elements	O
,	O
and	O
hence	O
the	O
exact	O
position	O
of	O
any	O
given	O
element	O
is	O
of	O
no	O
consequence	O
,	O
and	O
insert	O
is	O
carried	O
out	O
by	O
increasing	O
the	O
array	B-Data_Structure
size	O
by	O
1	O
and	O
storing	O
the	O
element	O
at	O
the	O
end	O
of	O
the	O
array	B-Data_Structure
,	O
which	O
is	O
a	O
O(1 )	O
operation	O
.	O
</s>
<s>
Likewise	O
,	O
the	O
deletion	O
operation	O
is	O
sometimes	O
quoted	O
as	O
being	O
O(n )	O
due	O
to	O
the	O
assumption	O
that	O
subsequent	O
elements	O
must	O
be	O
shifted	O
,	O
but	O
in	O
a	O
classic	O
unsorted	O
array	B-Data_Structure
the	O
order	O
is	O
unimportant	O
(	O
though	O
elements	O
are	O
implicitly	O
ordered	O
by	O
insert-time	O
)	O
,	O
so	O
deletion	O
can	O
be	O
carried	O
out	O
by	O
swapping	O
the	O
element	O
to	O
be	O
deleted	O
with	O
the	O
last	O
element	O
in	O
the	O
array	B-Data_Structure
and	O
then	O
decrementing	O
the	O
array	B-Data_Structure
size	O
by	O
1	O
,	O
which	O
is	O
a	O
O(1 )	O
operation	O
.	O
</s>
<s>
This	O
table	O
is	O
only	O
an	O
approximate	O
summary	O
;	O
for	O
each	O
data	B-General_Concept
structure	I-General_Concept
there	O
are	O
special	O
situations	O
and	O
variants	O
that	O
may	O
lead	O
to	O
different	O
costs	O
.	O
</s>
<s>
Also	O
two	O
or	O
more	O
data	B-General_Concept
structures	I-General_Concept
can	O
be	O
combined	O
to	O
obtain	O
lower	O
costs	O
.	O
</s>
