JKLJK

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

CMPSCI 611: Advanced Algorithms

Lecture 1

Andrew McGregor

Last Compiled: February 13, 2024

1/14
Outline

Introduction

Course Outline and Administrivia

Divide and Conquer

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?

I Good News: There’ll be no big project or programming assignments.


There’s a lot of math but you can collaborate on the homework.
I Bad News: The homework will be designed to make you think and
you’ll get stuck sometimes. Best way to learn the skill of algorithm
design is to try solving algorithmic problems that challenge you.
I Math Background: You’re expected to be able to write rigorous
mathematical proofs. May need to brush up on basic math:
probability, complex numbers, linear algebra, induction, etc.
I Algorithms Background: Official pre-requisite is an undergraduate
algorithms class. We’ll go through some undergrad topics but very
quickly. Students have taken the class without this but a) they
typically had a solid mathematics background and b) spent
considerably more time outside the class understanding the material.

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 )

log10 n = O(log2 n) (log n)100 = O(n) n10000 = O(e n )

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

Course Outline and Administrivia

Divide and Conquer

6/14
Basic Stuff

Lectures: Tuesday and Thursday, 10:00 to 11:15 am.


Lecturer: Andrew McGregor
I Email: mcgregor@cs.umass.edu

TA: Vinayak.
I Email: vvinayak@umass.edu

TA: Shuang Yang.


I Email: shuangyang@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

I Preliminaries, Divide and Conquer, FFT (3 lectures)


I Matroids and Greedy Algorithms (4 lectures)
I Dynamic Programming, Shortest Paths, Network Flow (4 lectures)
I Randomized Algorithms (4 lectures)
I Approximation Algorithms for NP-Hard Problems (7 lectures)
I Linear Programming (3 lectures)
More detail at:

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

Course Outline and Administrivia

Divide and Conquer

11/14
Merge Sort

Problem: Given an unsorted list of n numbers, sort them!


Algorithm
1. Divide list two halves.
2. Sort each half.
3. Merge the sorted halves.
Let running time of algorithm be T (n). Observe that for some constant
c, T (1) ≤ c and
T (n) ≤ 2T (n/2) + cn

12/14
Solving Recurrences: Master Theorem

More generally we can consider splitting a problem of size n into a


subproblems of size n/b.
Theorem
Suppose T (1) ≤ c and T (n) ≤ aT (n/b) + cnα for n > 1 where a, b, c, α
are some constants. Then

α
O(n )
 if a < b α
T (n) = O(nlogb a ) if a > b α

O(n log n) if a = b α
α

Therefore, Merge-Sort takes O(n log n) time since a = 2, b = 2, α = 1.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy