Problems and Algorithms

An outline of the lecture is given below.

Introductory Material

Big-O Notation

Big-O notation and its relatives are used to characterize the complexity of algorithms.

Let f and g be functions from the natural numbers to the natural numbers. We say f(n0=O(g(n) (f(n) is big-O (or of order) g(n)) if there are positive constants c and tex2html_wrap_inline110 such that tex2html_wrap_inline112 for all tex2html_wrap_inline114 . Informally, f grows no faster than g. Big-O notation is used to describe the (worst case) complexity of an algorithm.

Big-omega is used to describe that f grows no slower than g and would be used to describe the best case behavior of an algorithm or the inherent complexity of a problem. Big-theta is use to say f grows at the same rate as g.

The class P

The class of problems that can be solved in a polynomial number of steps in the size of the input. Algorithms to solve problems are executed on (deterministic) Turing machines.

Encoding Problems as Languages

A language L is a subset of the set of all strings over a finite alphabet. ``Problems'' can be encoded as languages. For example, a graph with n vertices can be represented as an adjacency matrix. Thus we can encode a graph as a string: the decimal number n, followed by a separator (say #), followed by a string of 0's and 1's of length tex2html_wrap_inline134 .

 

Decision Problems

A decision problem asks a question that requires a ``yes'' or ``no'' answer. REACHABILITY is an example

 

Reachability

REACHABILITY: Given a graph tex2html_wrap_inline136 and two nodes tex2html_wrap_inline138 , is there a path from 1 to n?

(All graphs will be finite and directed)

The search algorithm solves REACHABILITY.

REACH tex2html_wrap_inline144

tex2html_wrap_inline146 ;

while tex2html_wrap_inline148 do

remove i from S;

mark i;

for each edge tex2html_wrap_inline156 where j is not marked

insert j in S;

end for;

end while;

if n is marked return yes;

else return no;

Questions to consider

 

Optimization Problems

An optimization problem uses an objective function (cost criterion) to seek the best among many possible solutions to a problem. Any optimization problem can be transformed to a decision problem by supplying a target value.

 

Max Flow

MAX FLOW is an optimization problem on a network. A network tex2html_wrap_inline168 is a graph tex2html_wrap_inline136 with two distinguished nodes s (the source) and t (the sink) and an integer capacity tex2html_wrap_inline176 for each edge tex2html_wrap_inline156 . Additionally, the source s has no incoming edges and the sink t has no outgoing edges.

A flow in network N is a function tex2html_wrap_inline186 satisfying

  1. tex2html_wrap_inline188 for all edges tex2html_wrap_inline156 ,
  2. tex2html_wrap_inline192 for all nodes tex2html_wrap_inline194 (that is the sum of the flow of incoming edges equals the sum of the flow of outgoing edges).
The value of the flow is tex2html_wrap_inline196 or tex2html_wrap_inline198 .

MAX FLOW: Given a network, find a flow of largest possible value.

A ``cut'' in a network N=(V, E, s, t, c) is a set S such that the source is in S but the sink is not. The capacity of a cut is the sum of the capacities of all edges going out of S. The flow of a network is at least as large as the capacity of the capacity of any cut.

Let f be a flow. If f is not optimal and f' is another flow of greater value the tex2html_wrap_inline214 is a flow with positive value, but it may have negative flows along some edges (i, j), which can be thought of as a positive flow along the ``reverse'' edge.

If tex2html_wrap_inline218 , then tex2html_wrap_inline220 If tex2html_wrap_inline222 , then tex2html_wrap_inline224

tex2html_wrap_inline226 is a flow of the derived network N(f)=(V,E,s, t, c') where tex2html_wrap_inline230 and c'(i,j) = c(i,j) - f(i,j) for tex2html_wrap_inline234 and c'(i,j) = f(j,i) for tex2html_wrap_inline238 .

Deciding if a flow is optimal is the same as deciding whether there is a no positive flow in the derived network N(f). That is, showing t is not reachable from s. The MAX FLOW problem has been reduced to repeatedly solving REACHABILITY.

MAXFLOW tex2html_wrap_inline246

for each edge tex2html_wrap_inline234 set f(i,j)=0

constructs derived network N(f)

while t is reachable from s

find smallest capacity c' along N(f)'s path from s to t

add c' to the value of f on all edges of the path

constructs derived network N(f)

end while

return f;

What is the time complexity? Reachability and augmenting the flow is tex2html_wrap_inline274 . Each iteration increases the flow by at least 1. The maximum flow is at most nC where n is the number of vertices (not counting the source and sink) and C is the maximum capacity of any edge. The complexity is thus tex2html_wrap_inline282 .

Note the dependency on C can make this a non-polynomial algorithm. There are algorithms for MAXFLOW that are polynomial. The text gives a tex2html_wrap_inline286 algorithm.

Note the algorithm requires considerable extra space, about tex2html_wrap_inline134 to store the current flow.

NP Problems

Problems in the class NP can be solved in polynomial time on a non-deterministic Turing machine. A nice intuitive definition is that solutions to such problems can be ``checked'' quickly, but it may be time consuming to generate a solution.

 

The Traveling Salesman Problem

The traveling salesman problem (TSP): given a finite set of ``cities'' tex2html_wrap_inline290 and ``distances'' tex2html_wrap_inline292 between each pair of cities, and a bound tex2html_wrap_inline294 is there a ``tour'' of all cities having total length no more than B?



Florida Tech Computer Science

William D. Shoaff
Comments to author:wds@cs.fit.edu

All contents copyright ©, William D. Shoaff
Revised: Mon Jan 12 13:51:11 EST 1998