advanced algorithms
play

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


  1. ADVANCED ALGORITHMS Lecture 11: Review, flows/cuts

  2. 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

  3. TODAY’S PLAN ➤ Quick review/recap of course so far ➤ Comments about HW ➤ Flows and cuts in graphs ➤ Some applications of flows

  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 7 ➤ Usually prove correctness via induction ➤ How to solve a recurrence? (plug-n-chug, guess and prove, recurrence tree, Akra-Bazzi, master theorem, …) n time ➤ Examples: multiplying n -bit numbers, merge sort, median finding

  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

  6. EXAMPLE — COIN CHANGE ➤ Problem: given k denominations of coins d 1 , d 2 , …, d k , find how to make change for S cents using fewest number of coins It ➤ One way: let m(S, i) be the min number of coins needed to make change for S using coins d i and above. Recurrence tries all possibilities i dn di dit for # of d i coins: I m ( S , i ) = min j : jd i ≤ S j + m ( S − jd i , i + 1) m S di ith m Spiti It min S 2di Itil T paI Stl k 2tm Std Time for.mg iyES di overall times

  7. EXAMPLE — COIN CHANGE ➤ Problem: given k denominations of coins d 1 , d 2 , …, d k , 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 d i and above. Recurrence tries all possibilities for # of d i coins: m ( S , i ) = min j : jd i ≤ S j + m ( S − jd i , i + 1) ➤ Another: let f(S) be the min number of coins needed to make change for S. Recurrence tries all possible coins: f ( S ) = min i : d i ≤ S f ( S − d i )

  8. of coins needed to make f s min change for S Observation ft f for any di S i E It Obson 2 f It di s f s min denominations is.t di ES store all the ft values S Sp.ae S k Time denom 2,33 s 5 5 saz 0 s

  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

  10. GREEDY ALGORITHMS ➤ Basic idea: to make a sequence of choices, make one by one, best choice in each step. Greedy == myopic ➤ Typically: r ➤ 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! value

  11. LOCAL SEARCH ➤ Basic idea: start with an arbitrary solution, and try to improve by changing a lilthbi ➤ Typically: Pas ➤ 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

  12. It 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 e ffi ciently ➤ 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) F ➤ Takes n iterations, each taking m = |E| time ➤ Cool property: works also when graph has negative edges (but no cycles) tht Matri p

  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 e ffi ciently ➤ 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 minimum spanning hie Very similar to

  14. NEXT: CUTS & FLOWS

  15. CUTS IN GRAPHS ➤ Problem: given a graph, find a small set of (weighted) edges to “cut” so that the graph is disconnected . ➤ Variants: ii r O ➤ Separate given vertices u and v (called s-t cut) ➤ Break graph into two nearly equal pieces (partition) distributed ➤ Maximize the number of edges going between the two pieces ➤ Each variant has many applications maxut.im 9 D

  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 ed to t . 450 ➤ origins ot yo minimize total wt of edges out goat as to disconnect t fwm s so

  17. IEI m what is known IVI History n Cz nems Ford Fulkerson Polynomial time algorithm MY are harder than Directed graphs Ohm undirected ones n m Undirected graphs unweighted Okmtn bg I 903ns David Karger Radndomized algorithm Thorup 2015 Kawarabayashi

  18. MAXIMUM FLOW a weighted directed graph we are given Problemi interpreted as the capacity an edge is intea wt of flow from given amount of maximum Find the that does not violate to a t sink s source edge capacities the 50 0 o so iii

  19. ALGORITHMS FOR FLOW? send some flow Natural approaches capacities appropriately reduce another path exists etc find if not optimal does Not work in a systematic Can backtracking Yay

  20. MAXIMUM FLOW VS MIN CUT E ftow Value of max min cut of T fahe onto

Recommend


More recommend