Algorithms Books

Transcription

Algorithms Books
Algorithms


Course web site:
http://www.cs.uakron.edu/~zduan/class/435

Office: 238 CAS
Phone: 330330-972972-6773
E-mail: [email protected]
Office Hours: MWF12:00MWF12:00-1:00, MW6:25MW6:25-6:40, or appointment

Office hour: TBA (CAS 254),F5:00254),F5:00-7:00pm(CAS 241)





Teaching assistant: Vasudha Lankireddy

Tutors:
 Aaron Battershell and Michael Wilder
Course Goals:

Textbook:
Algorithms by Dasgupta
Dasgupta,, et al.
Instructor: Dr. ZhongZhong-Hui Duan


Books
An excellent reference:
Introduction to Algorithms, 3rd Edition,
by T.H. Cormen
Cormen,, C.E. Leiserson
Leiserson,, R.L.
Rivest,, and C. Stein, MIT, 2009.
Rivest
To learn well
well--known algorithms as well as the design and
analysis of these algorithms.
Program Submissions

Grading:





Weekly homework problems (15%).
 neat, clear, precise, formal.
Two exams (15%, 30%).
Programs (30%).
Quizzes & class participation (10%).
Grading Scale (+/(+/- grades may be assigned at
instructor's discretion):

A 9090-100 B 80
80--89 C 70
70--79 D 60
60--69 F 00-59
Dates and Final Exam Time


Last Day: Drop
Drop:: Sept 8; Withdraw
Withdraw:: Oct 13
Final Exam:
Exam: Given according to the University
Final Exam schedule.



MWF class : Thursday, Dec 11, 12:1512:15-2:15pm;
MW class : Wednesday, December 10, 4:45 - 6:45pm.

All programs will be submitted using Springboard
Springboard.. A drop box
will be created for each program. You will also need to submit a
printed copy of your source code and a readme file. DO NOT
submit programs that are not reasonably correct!
correct! To be considered
reasonably correct,
correct, a program must be completely documented and
work correctly for sample data provided with the assignment.
Programs failing to meet these minimum standards will be
returned ungraded and a 30% penalty assessed. Late points will be
added on top of this penalty.
Ethics: All programming assignments must be your own work.
work.
Duplicate or similar programs/reports, plagiarism, cheating, undue
collaboration, or other forms of academic dishonesty will be
reported to the Student Disciplinary Office as a violation of the
Student Honor Code.
Algorithm
A procedure for solving a computational problem
(ex: sorting a set of integers) in a finite number
of steps.
More specifically: a stepstep-byby-step procedure for
solving a problem or accomplishing something
(especially using a computer).
1
Solving a Computational Problem

Problem definition & specification





RSA.

Quicksort..
Quicksort

FFT.

Huffman codes.

Network flow.

Linear programming.

specify input, output and constraints
Algorithm analysis & design

Examples

devise a correct & efficient algorithm

Implementation planning
Coding, testing and verification


Input
Algorithm
Output

Cryptography.
Databases.
Signal processing.
Data compression.
Routing Internet packets.
Planning, decisiondecision-making.
What is CS435/535?

Learn wellwell-known
algorithms and the
design and analysis of
algorithms..
algorithms





Big--O notation
Big
Examine interesting
problems.
Devise algorithms for
solving them.
Data structures and core
algorithms.
Analyze running time of
programs.
Critical thinking.
thinking.
Asymptotic Complexity


Running time of an algorithm as a function of input
size n for large n.
Asymptotic Notation


Expressed using only the highest
highest--order term in the
expression for the exact running time.

Instead of exact running time, say Θ(n2).

Describes behavior of function in the limit.

Written using Asymptotic Notation.


Θ, O, Ω, o, ω
Defined for functions over the natural numbers.
numbers.
 Ex: f(n) = Θ(n2).
 Describes how f(n) grows in comparison to n2.
Define a set of functions; in practice used to compare
two function sizes.
The notations (Θ, O, Ω, o, ω) describe different rate
rate--ofofgrowth relations between the defining function and the
defined set of functions.
2
O-notation
Examples
O(g(n)) = {f(n) : ∃ positive constants c and n0,
such that ∀n ≥ n0, we have 0 ≤ f(n) ≤ cg(n) }
For function g(n), we define O(g(n)),
big-O of n, as the set:
O(g(n)) = {f(n) :
∃ positive constants c and n0,
such that ∀n ≥ n0,

n2 +1
 n2 +n
 1000
1000nn2 +1000n
 n1.999
 n2/log n
 n2/log log logn

we have 0 ≤ f(n) ≤ cg(n) }
Intuitively: Set of all functions whose
rate of growth is the same as or lower
than that of g(n).
O(n2)
Technically, f(n) ∈ O(g(n)).
Older usage, f(n) = O(g(n)).
g(n) is an asymptotic upper bound for f(n).
Ω -notation
For function g(n), we define Ω(g(n)),
big-Omega of n, as the set:
Ω(g(n)) = {f(n) :
∃ positive constants c and n0,
such that ∀n ≥ n0,
we have 0 ≤ cg(n) ≤ f(n)}
Intuitively: Set of all functions whose rate of growth is the
same as or higher than that of g(n).
g(n) is an asymptotic lower bound for f(n).
Example
Ω(g(n)) = {f(n) : ∃ positive constants c and n0, such
that ∀n ≥ n0, we have 0 ≤ cg(n) ≤ f(n)}







√n = Ω(lg n). Choose c and n0.
1000n2 + 1000n
1000n2 − 1000n
n3
n2.00001
n2 log log log n
22 n
Example
Θ-notation
For function g(n), we define Θ(g(n)),
big-Theta of n, as the set:
Θ(g(n)) = {f(n) :
∃ positive constants c1, c2, and n0,
such that ∀n ≥ n0,
we have 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n)
}
Intuitively: Set of all functions that have the same rate of
growth as g(n).
Θ(g(n)) = {f(n) : ∃ positive constants c1, c2, and n0,
such that ∀n ≥ n0, 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n)}



10nn2 - 3n = Θ(n2)
10
To compare orders of growth, look at the
leading term.
Exercise: Prove that n2/2
/2--3n= Θ(n2)
g(n) is an asymptotically tight bound for f(n).
3
Relations Between O, Ω, Θ
Exercise
n-106 = Ω(n)
Relations Between Θ, Ω, O
Example
3n3 =
3n
Θ(n4)

Is

How about 22n= Θ(2n)?

How about log2n = Θ(log10n)?
Theorem : For any two functions g(n) and f(n),
f(n) = Θ(g(n)) iff
f(n) = O(g(n)) and f(n) = Ω(g(n)).
?

i.e., Θ(g(n)) = O(g(n)) ∩ Ω(g(n))
f(n) = Θ(g(n)) ⇒ f(n) = O(g(n)).
Θ(g(n)) ⊂ O(g(n)).

In practice, asymptotically tight bounds are obtained
from asymptotic upper and lower bounds.
Properties
Comparison of Functions
f↔g ~ a↔b
f(n) = Θ(g(n)) ⇒ f(n) = Ω(g(n)).
Θ(g(n)) ⊂ Ω(g(n)).

Transitivity
f(n) = Θ(g(n)) and g(n) = Θ(h(n)) ⇒ f(n) = Θ(h(n))
f(n) = O(g(n)) and g(n) = O(h(n)) ⇒ f(n) = O(h(n))
f(n) = Ω(g(n)) and g(n) = Ω(h(n)) ⇒ f(n) = Ω(h(n))
f(n) = o (g(n)) and g(n) = o (h(n)) ⇒ f(n) = o (h(n))
f(n) = ω(g(n)) and g(n) = ω(h(n)) ⇒ f(n) = ω(h(n))
f (n) = O(
O(g(n)) ~ a ≤ b
f (n) = Ω(g(n)) ~ a ≥ b
f (n) = Θ(g(n)) ~ a = b

Reflexivity
f(n) = Θ(f(n))
f(n) = O(f(n))
f(n) = Ω(f(n))
4
Properties

Limits
Symmetry
f(n) = Θ(g(n)) iff g(n) = Θ(f(n))

lim [f(n) / g(n)] < ∞ ⇔ f(n) ∈ Ο(g(n))
n→∞

0 < lim [f(n) / g(n)] < ∞ ⇔ f(n) ∈ Θ(g(n))
n→∞

Complementarity
f(n) = O(g(n)) iff g(n) = Ω(f(n))
((ff(n))
f(n) = o(g(n)) iff g(n) = ω((

n→∞

constant
logarithmic
linear
nlogn
quadratic
cubic
exponential
exponential
etc.
lim [f(n) / g(n)] undefined ⇒ can’t say
n→∞
Fibonacci Numbers
complexity classes
adjective
0 < lim [f(n) / g(n)] ⇔ f(n) ∈ Ω(
Ω(g(n))
Θ-notation
Θ(1)
Θ(logn
logn))
Θ(n)
Θ(nlogn
nlogn))
Θ(n2)
Θ(n3)
Θ(2n)
Θ(10n)
HW due next Friday
Fibonacci Numbers

Ch0 1.a,c,e,g,i,o; 4.a,b
5