JKLJK
JKLJK
JKLJK
Lecture 1
Andrew McGregor
1/14
Outline
Introduction
2/14
Purpose and Goals of the Course
Design and mathematically analyze efficient algorithms:
I An “Algorithm” is any step-by-step procedure or method for solving
a problem where each step is simple and unambiguous.
I “Efficiency” isn’t measured in seconds but in how many basic steps
it takes and how this scales when the size of the problem grows.
I “Mathematically analyze” means proving algorithm satisfies
certain guarantees, e.g., always terminate within a certain number of
steps, always returns correct answer. . . The course has a lot of math.
Goals of course:
I Learn some specific algorithms and specific techniques.
I Learn the skill of designing algorithms, i.e., applying general
principles and some creativity to solve new problems and analyze
new algorithms that you have not seen before.
3/14
Is this course going to be hard?
4/14
Abstraction: Makes it easier to study “efficiency”
I Making an algorithm fast involves many considerations that are
architecture specific. For the sake of simplicity and generality, ignore
them! We will assume that any location in memory can be accessed
a unit cost and measure running time in “basic steps” such as
pairwise arithmetic operation and memory accesses.
I Don’t count steps exactly: Consider basic steps T (n) asymptotically
as the size of the problem n grows. If, for some function g (n) there
exists constants c, n0 ≥ 0 such that
T (n) ≤ cg (n) for all n > n0
then we say “T (n) is order g (n)” and write T (n) = O(g (n)). E.g.,
10n3 = O(n3 ) 5n2 + n + 1000 = O(n2 ) n2 = O(n5 )
I More notation: T (n) = Ω(g (n)) if there exists c, n0 > 0 such that
T (n) ≥ cg (n) for n larger than n0 . If T (n) = O(g (n)) and
T (n) = Ω(g (n)), we write T (n) = Θ(g (n)).
5/14
Outline
Introduction
6/14
Basic Stuff
TA: Vinayak.
I Email: vvinayak@umass.edu
For the quickest response, it’s almost always best to reach us via Piazza,
the class forum. Time and details of office hours are available via Moodle.
7/14
Textbooks and Materials
Most Useful
I Slides and lecture notes available on Moodle. We also refer to
sections of jeffe.cs.illinois.edu/teaching/algorithms
Useful Background:
I Cormen, Leiserson, Rivest, and Stein. Introduction to Algorithms
I Kleinberg and Tardos. Algorithm Design
I Dasgupta, Papadimitriou, Vazirani. Algorithms
Specific Topics in More Detail:
I Motwani and Raghavan. Randomized Algorithms
I Mitzenmacher and Upfal. Probability and Computing
I Vazirani. Approximation Algorithms
Websites:
I Slides: people.cs.umass.edu/~mcgregor/courses/CS611S24
I Quiz: moodle.umass.edu (everyone enrolled already has access)
I Homework: gradescope.com (will set up before first deadline)
I Piazza Discussion: Link is in Moodle. Please join today!
8/14
Course Outline
people.cs.umass.edu/~mcgregor/courses/CS611S24
Hopefully we’ll have time to incorporate some additional material, e.g.,
hashing and streaming, multiplicative weights method, clustering, . . .
9/14
Assessment
I Homework: Around 5 assignments contribute 25% to grade.
Collaboration allowed in groups of at most three. You are only
allowed to refer to slides and the textbooks; no searching on the web
or discussing with anyone outside your group.
I Quizzes: Weekly online quizzes contribute 15% to grade. No
collaboration.
I Exams: There will be two in-class midterms (each worth 15%) and
a final exam (worth 25%). No collaboration.
Midterms: March 14 and April 30
Final: May 14
I Participation: 5% of grade will be based on forum participation,
i.e., asking good questions and helping other students.
I Cheating in exam results in an F for the course. First cheating
offense for homework or quiz results in 0% for that activity but
second such offense results in an F for the course. Email for
clarification if anything isn’t clear.
I Late Policy: No late quizzes allowed but we’ll drop everyone’s
weakest quiz. At most one homework may be 48 hours late but
beyond that late home gets a zero.
10/14
Outline
Introduction
11/14
Merge Sort
12/14
Solving Recurrences: Master Theorem
13/14
Proof
I Assume n is a power of b but theorem holds in general.
I Let W (n) = cnα and repeatedly expand T (n) to get
T (n) ≤ aT (n/b) + W (n)
≤ a2 T (n/b 2 ) + aW (n/b) + W (n)
≤ a3 T (n/b 3 ) + a2 W (n/b 2 ) + aW (n/b) + W (n)
≤ ...
≤ alogb n T (1) + alogb n−1 W (n/b logb n−1 ) + . . . + aW (n/b) + W (n)
≤ alogb n W (n/b logb n ) + alogb n−1 W (n/b logb n−1 ) + . . . + aW (n/b) + W (n)
= cnα (r logb n + r logb n−1 + . . . + r + 1) where r = a/b α
I If r = 1 and T (n) ≤ cnα (1 + logb n) = O(nα log n)
I If r < 1 and
1 − r 1+logb n
T (n) ≤ cnα = O(nα )
1−r
I If r > 1, then
1+log n
r b −1
T (n) ≤ cnα = O(nα r logb n ) = O(nlogb a )
r −1
14/14