Design and Analysis of Algorithms
Chapter 11
How to tackle those difficult problems.
Exact solutions
There are two principal approaches to tackling NP-hard
NPproblems or other intractable problems:
The exact solution approach includes the strategies:
exha
Design and Analysis of Algorithms
Our old list of problems
Classifying a problems complexity
Sorting
Searching
Shortest paths in a graph
Minimum spanning tree
Primality testing
Traveling salesman problem
Knapsack problem
Chess
Towers of Hanoi
Program term
Design and Analysis of Algorithms
Dynamic Programming
Dynamic Programming is a general algorithm design technique Invented by American mathematician Richard Bellman in the 1950s to solve optimization problems Programming here means planning Main idea: so
Design and Analysis of Algorithms
Greedy algorithms
Chapter 9
Applications of the Greedy Strategy
Optimization problems solved through a sequence of choices
that are:
feasible
Optimal solutions:
locally optimal
irrevocable
change making
Minimum Spanning T
Design and Analysis of Algorithms
Chapter 7
SpaceSpace-time tradeoffs
String matching
For many problems some extra space really pays off:
? extra space in tables (breathing room?)
hashing
non comparison-based sorting
comparison-
?
?
?
pattern:
pattern:
Design and Analysis of Algorithms
Decrease and Conquer
1.
2.
3.
Chapter 5
Examples of Decrease and Conquer
Reduce problem instance to smaller instance of the same
problem and extend solution
Solve smaller instance
Extend solution of smaller instance to ob
Design and Analysis of Algorithms
Transform and Conquer
Chapter 6
Instance simplification - Presorting
Solve problem by transforming into:
? a more convenient instance of the same problem (instance implification)
(instance implification)
presorting
Gaus
Design and Analysis of Algorithms
Analysis of Algorithms
Theoretical analysis of time efficiency
Time efficiency is analyzed by determining the number of
repetitions of the basic operation as a function of input size
Issues:
Chapter 2
Correctness
Time eff
Design and Analysis of Algorithms
Divide and Conquer
Chapter 4
Divide-and-conquer technique
Divide- and-
The most well known algorithm design strategy:
1.
Divide instance of problem into two or more smaller
instances
2.
subproblem 1
of size n/2
Obtain sol
Design and Analysis of Algorithms
Brute Force
String matching
A straightforward approach usually based on problem
statement and definitions
Examples:
1.
Computing an (a > 0, n a nonnegative integer)
2.
3.
Chapter 3
pattern: a string of m characters to sea
Design and Analysis of Algorithms
Algorithm
Chapter 1
Historical Perspective
Euclids algorithm for finding the greatest common divisor
An algorithm is a sequence of unambiguous
instructions for solving a problem, i.e., for
obtaining a required output for
How to tackle those difficult
problems.
There are two principal approaches to tackling NP-hard
problems or other intractable problems:
Use a strategy that guarantees solving the problem exactly
but doesnt guarantee to find a solution in polynomial time
Us
Our old list of problems
Sorting
Searching
Shortest paths in a graph
Minimum spanning tree
Primality testing
Traveling salesman problem
Knapsack problem
Chess
Towers of Hanoi
Program termination
Design and Analysis of Algorithms - Chapter 10
1
Classifying
Transform and Conquer
Solve problem by transforming into:
a more convenient instance of the same problem (instance implification)
presorting
Gaussian elimination
a different representation of the same instance (representation change)
balanced search tr
Decrease and Conquer
1.
2.
3.
Reduce problem instance to smaller instance of the same
problem and extend solution
Solve smaller instance
Extend solution of smaller instance to obtain solution to
original problem
Also referred to as inductive or incrementa
Greedy algorithms
Optimization problems solved through a sequence of choices
that are:
feasible
locally optimal
irrevocable
Not all optimization problems can be approached in this
manner!
Design and Analysis of Algorithms - Chapter 9
1
Applications of the
Divide and Conquer
The most well known algorithm design strategy:
1.
Divide instance of problem into two or more smaller
instances
2.
Solve smaller instances recursively
3.
Obtain solution to original (larger) instance by combining
these solutions
Design
Dynamic Programming
Dynamic Programming is a general algorithm design
technique
Invented by American mathematician Richard Bellman in
the 1950s to solve optimization problems
Programming here means planning
Main idea:
solve several smaller (overlappi
Analysis of Algorithms
Issues:
Correctness
Time efficiency
Space efficiency
Optimality
Approaches:
Theoretical analysis
Empirical analysis
Design and Analysis of Algorithms - Chapter 2
1
Theoretical analysis of time
efficiency
Time efficiency is analyze
Brute Force
A straightforward approach usually based on problem
statement and definitions
Examples:
1.
Computing an (a > 0, n a nonnegative integer)
2.
3.
Computing n!
Multiply two n by n matrices
4.
Selection sort
5.
Sequential search
Design and Analysis
Space-time tradeoffs
For many problems some extra space really pays off:
extra space in tables (breathing room?)
hashing
non comparison-based sorting
input enhancement
indexing schemes (eg, B-trees)
auxiliary tables (shift tables for pattern matching)
Algorithm
An algorithm is a sequence of unambiguous
instructions for solving a problem, i.e., for
obtaining a required output for any legitimate
input in a finite amount of time.
Design and Analysis of Algorithms - Chapter 1
1
Historical Perspective
Eucli