Introduction 1. Introduction - 1

advertisement
Introduction
CS3381 Des & Anal of Alg (2001-2002 SemA)
City Univ of HK / Dept of CS / Helena Wong
http://www.cs.cityu.edu.hk/~helena
1. Introduction - 1
What is an Algorithm?
An algorithm is:
a sequence of elementary
computational steps that transforms
the input into the output.
An algorithm is:
a tool for solving a well-specified
computational problem, eg.
Sorting, Multiplication.
A correct algorithm: for every input instance, it halts with
the correct output.
CS3381 Des & Anal of Alg (2001-2002 SemA)
City Univ of HK / Dept of CS / Helena Wong
http://www.cs.cityu.edu.hk/~helena
1. Introduction - 2
A Sorting Problem
A Sorting Problem
Input
: <a1, a2, …, an>
Output
: A permutation (re-ordering) < a’1, a’2, …, a’n> of
the input sequence such that a’1 a’2  …  a’n.
Example:
<31, 41, 59, 26, 41, 58> => <
>
An instance
of the sorting
problem.
CS3381 Des & Anal of Alg (2001-2002 SemA)
City Univ of HK / Dept of CS / Helena Wong
http://www.cs.cityu.edu.hk/~helena
1. Introduction - 3
The best algorithm
Which algorithm is best, eg. for a sorting problem?
Answer these questions first:
Number of items to be sorted?
Are the items already somewhat sorted?
Any restrictions on the item values?
What kind of storage device (main memory? Disks?)
CS3381 Des & Anal of Alg (2001-2002 SemA)
City Univ of HK / Dept of CS / Helena Wong
http://www.cs.cityu.edu.hk/~helena
1. Introduction - 4
Other examples of problems
Identifying 100,000 genes in human DNA.
Determining the sequences of 3,000,000,000 base pairs.
=> Sorting and Order statistics
Internet search engine
=> Graph algorithms, hash tables, string matching
Find all x and n that satisfies 1079*x = 80642173 (mod n)
Cryptography and digital signatures
=> Numerical problems
CS3381 Des & Anal of Alg (2001-2002 SemA)
City Univ of HK / Dept of CS / Helena Wong
http://www.cs.cityu.edu.hk/~helena
1. Introduction - 5
Other examples of problems
Winning an election
Policy
Zone
A
Zone
B
Zone
C
=> Linear Programming
Build Roads
-2000
5000
3000
Gun Control
8000
2000
-500
Triangulation of polygon
=> Dynamic Programming
Identifying the convex hull
=> Computational Geometry
CS3381 Des & Anal of Alg (2001-2002 SemA)
City Univ of HK / Dept of CS / Helena Wong
http://www.cs.cityu.edu.hk/~helena
1. Introduction - 6
NP-Complete Problems
All known problems:
Tractable: The set of problems
with efficient solutions known.
No efficient solution is
known yet.
NP-Complete Problems
Nobody has ever proven that an efficient algorithm for one cannot
exist.
If an efficient algorithm exists for any one of them, then efficient
algorithms exist for all of them !!!
Several NP-Complete problems are similar to some tractable ones.
Eg. Traveling-salesman problem
However, “Approximation Algorithms” exist !!!
CS3381 Des & Anal of Alg (2001-2002 SemA)
City Univ of HK / Dept of CS / Helena Wong
http://www.cs.cityu.edu.hk/~helena
1. Introduction - 7
Core Topics
Analysis of Algorithms
Computational Geometry
Divide and Conquer
Graph Algorithms
Dynamic Programming
String Algorithms
Greedy Algorithms
NP-Completeness
CS3381 Des & Anal of Alg (2001-2002 SemA)
City Univ of HK / Dept of CS / Helena Wong
http://www.cs.cityu.edu.hk/~helena
1. Introduction - 8
Download