18
Chapter
2.
Basic Definitions
2.3
Algorithms
and
Complexity
Although
complexity
is
not
a central topic in this book,
we
will encounter a
number
of problems for which one
is
interested in
their
complexity
status.
We
will
not
define in a precise
mathematical
way
the
notions of algorithms
and
complexity. We only give here some 'naive' definitions, which should be sufficient
for
our
purpose. Precise definitions can be found, e.g.,
in
the
textbooks
by
Garey
and
Johnson
[1979], or
Papadimitriou
and
Steiglitz [1982].
Let
(P)
be a
problem
and
suppose, for convenience,
that
(P)
is
a decision
problem
(that
is, a
problem
which asks for a 'yes' or
'no'
answer).
We
may
take,
for instance, for (P) any of
the
following problems:
(PI)
The
i1-embeddability
problem.
Instance: A
rational
valued distance d
on
a set
Vn
=
{I,
...
,n}.
Question: Is d isometrically
iI-embeddable?
That
is, do
there
exist vectors
VI,
...
,
Vn
E qn (for some m
2:
1) such
that
d(i,j)
=
dCl
(Vi,
v
J
)
for all
i,j
E
Vn
?
(P2)
The
hypercube
embeddability
problem
for
graphs.
Instance: A
graph
G = (V,
E).
Question:
Can
G be isometrically
embedded
into some
hypercube?
An
instance
of
a problem
is
specified by providing a
certain
input.
(For
(PI),
the
input
consists of
the
G)
numbers
d(
i,
j)
while, for (P2),
the
input
consists
of
a
graph
G which can, for instance, be described by its adjacency
matrix.)
The
size of
an
instance is
the
number
of
bits
needed to represent
the
input
data
in
binary
encoding. (For instance,
the
size of
an
integer p is size(p) =
rlog2
(Ipl
+
l)l;
the
size of a
rational
number
~
is
size(p) + size(
q)
+
1;
the
size
of
an
m x n
rational
matrix
A
is
mn
+ L:i,j size(aij), etc.) Suppose
that
we
have
an
algorithm
for solving
(P).
Its
complexity is measured by counting
the
total
number
of
elementary
steps
needed to be performed
throughout
the
execution
of
the
algorithm
(elementary steps such as
arithmetic
operations, comparisons,
branching instructions, etc., are supposed to take a
unit
time).
The
algorithm
is
said to have a polynomial running time if
the
total
number
of elementary steps
can
be
expressed as p(l), where p(.)
is
a polynomial function
and
I is
the
size of
the
instance.
Problems
are classified into several complexity classes.
The
class P consists
of
the
decision problems which can be solved in polynomial time.
The
class
NP
consists of
the
decision problems for which every 'yes' answer
admits
a certificate
that
can
be checked in polynomial
time
(but
one does
not
need to know how to
find such a certificate
in
polynomial time). Similarly, a
problem
is
in co-NP if
every
'no'
answer
admits
a certificate
that
can
be checked
in
polynomial time.
Hence, P
S;;
NP
n co-NP.
For example,
the
problem
(PI)
belongs to
NP
(because
it
can be shown
that,
if d is
iI-embeddable,
then
there
exists a
set
of vectors
VI,
.
..
,V
n
E
lW.(;)
providing
an
iI-embedding
of d
and
such
that
the
size of
the
vi's is polynomially
bounded
by
that
of
d;
see Section 4.4).
On
the
other
hand,
as
we
will see
in
Chapter
19,
the
problem (P2) belongs to P.