ADVANCED ALGORITHMS Lecture 11: Review, flows/cuts ANNOUNCEMENTS - - PDF document

advanced algorithms
SMART_READER_LITE
LIVE PREVIEW

ADVANCED ALGORITHMS Lecture 11: Review, flows/cuts ANNOUNCEMENTS - - PDF document

ADVANCED ALGORITHMS Lecture 11: Review, flows/cuts ANNOUNCEMENTS 5 Hong g HW 1 grades out (?) Maheshakya 2 Amin 034 HW 2 due this Friday, 11:59 PM sravein I 43 gIouglegroups.com utah algo ta way ym.nu gym TODAYS PLAN Quick


slide-1
SLIDE 1

ADVANCED ALGORITHMS

Lecture 11: Review, flows/cuts

slide-2
SLIDE 2

ANNOUNCEMENTS

➤ HW 1 grades out (?) ➤ HW 2 due this Friday, 11:59 PM

g

Hong

5

Maheshakya 2

Amin

034

sravein I 43 utah algo ta

gIouglegroups.com

gym

way ym.nu

slide-3
SLIDE 3

TODAY’S PLAN

➤ Quick review/recap of course so far ➤ Comments about HW ➤ Flows and cuts in graphs ➤ Some applications of flows

slide-4
SLIDE 4

DIVIDE & CONQUER

➤ Basic idea: divide instance into sub-problems, solve them recursively,

combine

➤ Usually sub-problems don’t overlap much ➤ Analysis by writing down a recurrence ➤ Usually prove correctness via induction ➤ How to solve a recurrence? (plug-n-chug, guess and prove, recurrence

tree, Akra-Bazzi, master theorem, …)

➤ Examples: multiplying n-bit numbers, merge sort, median finding

7

n time

slide-5
SLIDE 5

DYNAMIC PROGRAMMING

➤ Basic idea: write down a recursive expression for quantity of interest,

store answers to all “sub-problems”

➤ Works well if # of distinct sub-problems is small ➤ Examples: subset sum, coin change, longest increasing subsequence,

➤ Key: how we write recurrence determines space/time ➤ See notes: top down vs bottom up

slide-6
SLIDE 6

EXAMPLE — COIN CHANGE

➤ Problem: given k denominations of coins d1, d2, …, dk, find how to

make change for S cents using fewest number of coins

➤ One way: let m(S, i) be the min number of coins needed to make

change for S using coins di and above. Recurrence tries all possibilities for # of di coins:

m(S, i) = min

j : jdi≤S j + m(S − jdi, i + 1)

It

di dit

i dn

I min

m Spiti

It

m S di ith

TpaI

Stl

k

2tm

S 2di Itil

Time for.mgiyESdi

Std

  • veralltimes
slide-7
SLIDE 7

EXAMPLE — COIN CHANGE

➤ Problem: given k denominations of coins d1, d2, …, dk, find how to

make change for S cents using fewest number of coins

➤ One way: let m(S, i) be the min number of coins needed to make

change for S using coins di and above. Recurrence tries all possibilities for # of di coins:

➤ Another: let f(S) be the min number of coins needed to make change

for S. Recurrence tries all possible coins:

m(S, i) = min

j : jdi≤S j + m(S − jdi, i + 1)

f(S) = min

i : di≤S f(S − di)

slide-8
SLIDE 8

f s

min

  • f coins needed tomake

changefor S

Observation

ft

E

It

f

S

di

for any

i

Obson 2

f s

min

It

f

s

di

denominations

is.t

di ES

Sp.ae

S

store all the ft

values

Time

S k

denom

s

2,33

5

5 s

saz

slide-9
SLIDE 9

DYNAMIC PROGRAMMING

➤ Basic idea: write down a recursive expression for quantity of interest,

store answers to all “sub-problems”

➤ Works well if # of distinct sub-problems is small ➤ Examples: subset sum, coin change, longest increasing subsequence,

➤ Key: how we write recurrence determines space/time ➤ See notes: top down vs bottom up

slide-10
SLIDE 10

GREEDY ALGORITHMS

➤ Basic idea: to make a sequence of choices, make one by one, best

choice in each step. Greedy == myopic

➤ Typically: ➤ easy to design algorithm & implement ➤ Not easy to analyze ➤ Doesn’t produce optimal answers ➤ Examples: matching gifts to children, scheduling, spanning trees,

hiring problem — first example of approximation — always at least 63% of optimum!

r

value

slide-11
SLIDE 11

LOCAL SEARCH

➤ Basic idea: start with an arbitrary solution, and try to improve ➤ Typically: ➤ easy to design algorithm & implement ➤ how we swap determines running time (usually large) ➤ produces reasonable answers (esp in practice) ➤ Examples: matching gifts to children (always 1/2 of optimum),

gradient descent is example of local search

by changing a lilthbi

Pas

slide-12
SLIDE 12

BASIC GRAPH ALGORITHMS

➤ Shortest paths ➤ Problem: given a directed graph with edge lengths, find the shortest

total length path from u to v. Can be done efficiently

➤ Bellman-Ford/Shimbel’s algorithm: maintain “candidate” dist[w]

values for all vertices w. Update all using 
 dist[w] = min(dist[w], dist[i] + len(i, w)) for all edges (i,w)

➤ Takes n iterations, each taking m = |E| time ➤ Cool property: works also when graph has negative edges (but no

cycles)

It

F

Matri

p

tht

slide-13
SLIDE 13

BASIC GRAPH ALGORITHMS

➤ Shortest paths ➤ Problem: given a directed graph with edge lengths, find the shortest

total length path from u to v. Can be done efficiently

➤ Dijkstra’s algorithm: maintain “candidate” dist[w] values for all

vertices w. Grow “ball of certain radius” around u.

➤ Add one vertex to ball in each iteration — pick one that has least

dist[] value; update dist[] values

➤ Properties: near linear time; doesn’t work with negative edges

Very similar to

minimum spanning hie

slide-14
SLIDE 14

NEXT: CUTS & FLOWS

slide-15
SLIDE 15

CUTS IN GRAPHS

➤ Problem: given a graph, find a small set of (weighted) edges to “cut”

so that the graph is disconnected.

➤ Variants: ➤ Separate given vertices u and v (called s-t cut) ➤ Break graph into two nearly equal pieces (partition) ➤ Maximize the number of edges going between the two pieces ➤ Each variant has many applications

r

ii

O

distributed

maxut.im9 D

slide-16
SLIDE 16

MIN S-T CUT

➤ Problem: given a directed graph with edge weights, find a small set of

(weighted) edges to “cut” so that there is no longer a direct path from s to t.

➤ origins

yo

450

ed

  • t

goat

minimize total wt of edges out

so

as to disconnect t fwm

s

slide-17
SLIDE 17

m

IEI

History

what is known

n

IVI

nems

Cz

Polynomial time algorithm

Ford Fulkerson

MY

Directed

graphs

are harder than

m

Ohm

n

undirectedones

Undirected graphs

unweighted

Okmtn bg I

903ns

David Karger

Radndomized algorithm 2015

Thorup

Kawarabayashi

slide-18
SLIDE 18
slide-19
SLIDE 19

MAXIMUM FLOW

Problemi

we are given

a weighted directed graph

intea wt of

an edge is

interpreted as the

capacity

Find

the

maximum

amount of

flow from given

source

s

to a t

sink

that does not violate

the

edge capacities 50

  • iii

so

slide-20
SLIDE 20

ALGORITHMS FOR FLOW?

Natural approaches

send someflow reduce

capacities appropriately

find if

another path exists etc does Not work

not optimal

Can

backtracking

in

a systematic

Yay

slide-21
SLIDE 21

MAXIMUM FLOW VS MIN CUT

Value of

max

ftow

E

T fahe

  • f

min cut

  • nto