Computability and Complexity
23-1
Search and Optimization
Computability and Complexity
Andrei Bulatov
Computability and Complexity
Search Problems
Often we need to find a solution to some problem, rather than to show
that a solution exists
In this case the problem is said to be a search problem
Hamilton Circuit(S)
Instance: A finite graph G.
Objective: Find a Hamilton Circuit in G, or report it does not
exist
23-2
Computability and Complexity
More Examples
Colouring(S)
Instance: A finite graph G and an integer K.
Objective: Find a colouring of G with K colours or report it does
not exist
Satisfiability(S)
Instance: A conjunctive normal form .
Objective: Find a satisfying assignment for or report it does
not exist
23-3
Computability and Complexity
Reduction to Decision Versions
Search problems look much more practical than decision problems,
but we have studied mostly decision problems because:
• there always is the decision version of a search problem
• complexity classes, reducibility, etc. for decision problems
are simpler than those for search problems
• normally, if we know how to solve a decision problem, we can
also solve its search version
23-4
Computability and Complexity
Reduction for Satisfiability
We use an algorithm for the decision version as an oracle
Given a formula with the set of variables V
• For every X V do
• If |X 0 has a satisfying assignment set X = 0
- otherwise, if | X 1 has a satisfying assignment set X = 1
otherwise report “there is no solution”
• output the obtained assignment
23-5
Computability and Complexity
23-6
Reduction for HamCircuit
Observation:
G:
v
A graph G has a
Hamilton Path from u to
v if and only if the
following graph has a
Hamilton Circuit
u
v
u
Computability and Complexity
Given a graph G with vertex set V
• take a vertex v0 V
• set H := G
• for i= 1 to |V| –1 do
• for every neighbour v of vi1 do
- if there is a Hamilton path in H from v0 to v then
set vi : v
remove vi and all adjacent edges from H
• until vi is defined
• if vi is not defined then output “there is no Hamilton Circuit”
• output the Hamilton Circuit
v0 , v1 ,, v|V |1
23-7
Computability and Complexity
Optimization Problems
In some problems we seek to find the best solution among a collection
of possible solutions
Problems of this type are called optimization problems
Definition
An optimization problem is a 4-tuple (I,S,m,opt), where
• I is a set of possible instances (encoded by strings over
some alphabet
• S is a function mapping each instance to a set of
feasible solutions
• m is a function mapping pairs of instances and
solutions to a positive measure of goodness
• opt is either max or min, and indicates whether we
seek maximum or minimum goodness
23-8
Computability and Complexity
To solve an optimization problem we must find for any given x I, a
solution y S(x) such that
m( x, y ) opt{m( x, z ) | z S ( x)}
The optimal value will be denoted OPT(x)
23-9
Computability and Complexity
Example
Travelling Salesperson(O)
Instance: A finite set of cities {c1 , c2 ,, cn }, and a positive integer
distance d (i, j ) , between each pair {ci , c j }.
Objective: Find a permutation of {1,, n} that minimizes
n1
d ( (i ), (i 1)) d ( (n ), (1))
i 1
• I contains sets of cities and distances
• S gives the set of all possible orderings for each instance
• m gives the length of the tour for each instance and choice of ordering
• opt is min, because we seek for a shortest tour
23-10
Computability and Complexity
Example
Minimal Vertex Cover¹
Instance: A graph G = (V,E).
Objective: Find a smallest set M N such that for each edge
(u,v) E we have u,v M
¹Sometimes called Min Node Cover or just Minimum Cover
• I contains all graphs
• S gives the set of all vertex covers for each graph
• m gives the size of the vertex cover (the number of vertices)
• opt is min, because we seek for a smallest vertex cover
23-11
Computability and Complexity
NP-Hard
By extending the notion of reduction, we can show that many
optimization problems are hard to solve
Algorithms for the examples above would allow us to solve the
corresponding decision problems, which are all NP-complete
We will call a problem NP-hard if all problems in NP are
reducible to it in polynomial time
23-12
Computability and Complexity
Reduction for TSP
Given a set of cities {c1 , c2 ,, cn } and distances d (i, j )
First, we find the length of the shortest tour
• set L := 0 and U : n max{d (i, j )}
• do
L U
- set M :
2
- if there is a tour of length M then
set U := M
- otherwise set L := M
• until L = U
• return L
23-13
Computability and Complexity
Now we can find a shortest tour. Let its length be denoted L and let B = 2L
• set v0 : c1
• for i = 1 to n –1 do
• for every v {c1 ,, cn } {v0 ,, vi 1} do
- suppose v ck
- set d ' (vi 1 , ck ) 0 and d ' ( j, l ) d ( j, l ) otherwise
- if there is a tour for {c1 , c2 ,, cn } and d ' ( j, l )
of length L d ' (vi 1 , ck ) then
set vi : v
set d ' (vi 1 , ck ) : 0 and L : L d ' (vi 1 , ck )
• until vi is defined
• output the shortest tour v0 , v1 ,, v|V |1
23-14
Computability and Complexity
Both, search and optimization problems can be reduced to decision
problems
Why optimization problems are more interesting?
Because we can approximate…
23-15
© Copyright 2026 Paperzz