Presentation is loading. Please wait.

Presentation is loading. Please wait.

Final Exam Review Final exam will have the similar format and requirements as Mid-term exam: Closed book, no computer, no smartphone Calculator is Ok Final.

Similar presentations


Presentation on theme: "Final Exam Review Final exam will have the similar format and requirements as Mid-term exam: Closed book, no computer, no smartphone Calculator is Ok Final."— Presentation transcript:

1 Final Exam Review Final exam will have the similar format and requirements as Mid-term exam: Closed book, no computer, no smartphone Calculator is Ok Final exam questions are contained in: Questions in Homework 2 and Programming Assignment 2 Content listed in the following slides

2 2 String Similarity How similar are two strings? n ocurrance n occurrence ocurrance ccurrenceo - ocurrnce ccurrnceo --a e- ocurrance ccurrenceo - 6 mismatches, 1 gap 1 mismatch, 1 gap 0 mismatches, 3 gaps

3 3 Applications. n Basis for Unix diff. n Speech recognition. n Computational biology. Edit distance. [Levenshtein 1966, Needleman-Wunsch 1970] n Gap penalty  ; mismatch penalty  pq. n Cost = sum of gap and mismatch penalties. 2  +  CA CGACCTACCT CTGACTACAT TGACCTACCT CTGACTACAT - T C C C  TC +  GT +  AG + 2  CA - Edit Distance

4 4 Goal: Given two strings X = x 1 x 2... x m and Y = y 1 y 2... y n find alignment of minimum cost. Def. An alignment M is a set of ordered pairs x i -y j such that each item occurs in at most one pair and no crossings. Def. The pair x i -y j and x i' -y j' cross if i j'. Ex: CTACCG vs. TACATG. Sol: M = x 2 -y 1, x 3 -y 2, x 4 -y 3, x 5 -y 4, x 6 -y 6. Sequence Alignment CTACC- TACAT- G G y1y1 y2y2 y3y3 y4y4 y5y5 y6y6 x2x2 x3x3 x4x4 x5x5 x1x1 x6x6

5 5 Def. An s-t cut is a partition (A, B) of V with s  A and t  B. Def. The capacity of a cut (A, B) is: Cuts s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 Capacity = 10 + 5 + 15 = 30 A

6 6 s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 A Cuts Def. An s-t cut is a partition (A, B) of V with s  A and t  B. Def. The capacity of a cut (A, B) is: Capacity = 9 + 15 + 8 + 30 = 62

7 7 Residual Graph Original edge: e = (u, v)  E. n Flow f(e), capacity c(e). Residual edge. n "Undo" flow sent. n e = (u, v) and e R = (v, u). n Residual capacity: Residual graph: G f = (V, E f ). n Residual edges with positive residual capacity. n E f = {e : f(e) 0}. uv 17 6 capacity uv 11 residual capacity 6 flow

8 8 Ford-Fulkerson Algorithm s 2 3 4 5t 10 9 8 4 6 2 G : capacity

9 9 Augmenting Path Algorithm Augment(f, c, P) { b  bottleneck(P) foreach e  P { if (e  E) f(e)  f(e) + b else f(e R )  f(e R ) - b } return f } Ford-Fulkerson(G, s, t, c) { foreach e  E f(e)  0 G f  residual graph while (there exists augmenting path P) { f  Augment(f, c, P) update G f } return f } forward edge reverse edge

10 10 Certifiers and Certificates: 3-Satisfiability (3-SAT) SAT. Given a CNF formula , is there a satisfying assignment? Certificate. An assignment of truth values to the n boolean variables. Certifier. Check that each clause in  has at least one true literal. Ex. Conclusion. SAT is in NP. instance s certificate t

11 11 Subset Sum SUBSET-SUM. Given natural numbers w 1, …, w n and an integer W, is there a subset that adds up to exactly W? Ex: { 1, 4, 16, 64, 256, 1040, 1041, 1093, 1284, 1344 }, W = 3754. Yes. 1 + 16 + 64 + 256 + 1040 + 1093 + 1284 = 3754. Remark. With arithmetic problems, input integers are encoded in binary. Polynomial reduction must be polynomial in binary encoding. Claim. 3-SAT  P SUBSET-SUM. Pf. Given an instance  of 3-SAT, we construct an instance of SUBSET- SUM that has solution iff  is satisfiable.

12 12 Subset Sum Construction. Given 3-SAT instance  with n variables and k clauses, form 2n + 2k decimal integers, each of n+k digits, as illustrated below. Claim.  is satisfiable iff there exists a subset that sums to W. Pf. No carries possible. dummies to get clause columns to sum to 4 y x z 000010 000200 000100 001001 010011 010100 100101 100010 001110 xyzC1C1 C2C2 C3C3 000002 000001 000020 111444  x x  y y  z z W 10 200 100 1,001 10,011 10,100 100,101 100,010 1,110 2 1 20 111,444

13 13 Weighted Vertex Cover Definition. Given a graph G = (V, E), a vertex cover is a set S  V such that each edge in E has at least one end in S. Weighted vertex cover. Given a graph G with vertex weights, find a vertex cover of minimum weight. (NP hard problem) all nodes with weight of 1 reduces the problem to standard vertex cover problem. 4 9 2 2 4 9 2 2 weight = 2 + 2 + 4 weight = 11

14 14 Pricing Method Pricing method. Set prices and find vertex cover simultaneously. Why S is a vertex cover set? (use contradiction to prove) Weighted-Vertex-Cover-Approx(G, w) { foreach e in E p e = 0 while (  edge e=(i,j) such that neither i nor j are tight) select such an edge e increase p e as much as possible until i or j tight } S  set of all tight nodes return S }

15 15 Approximation method: Pricing Method Pricing method. Each edge must be covered by some vertex. Edge e = (i, j) pays price p e  0 to use vertex i and j. Fairness. Edges incident to vertex i should pay  w i in total. Lemma. For any vertex cover S and any fair prices p e :  e p e  w(S). Pf. ▪ 4 9 2 2 sum fairness inequalities for each node in S each edge e covered by at least one node in S

16 16 Pricing Method vertex weight Figure 11.8 price of edge a-b Example shows the pricing method does not provide the optimal weighted vertex cover solution

17 17 Weighted Vertex Cover: IP Formulation Weighted vertex cover. Given an undirected graph G = (V, E) with vertex weights w i  0, find a minimum weight subset of nodes S such that every edge is incident to at least one vertex in S. Integer programming formulation. n Model inclusion of each vertex i using a 0/1 variable x i. Vertex covers in 1-1 correspondence with 0/1 assignments: S = {i  V : x i = 1} n Objective function: minimize  i w i x i. – Constraints:….. n Must take either i or j: x i + x j  1.

18 18 Weighted Vertex Cover: IP Formulation Weighted vertex cover. Integer programming formulation. Task: Show the concrete ILP equation set for an example graph.

19 19 Weighted Vertex Cover Weighted vertex cover. Given an undirected graph G = (V, E) with vertex weights w i  0, find a minimum weight subset of nodes S such that every edge is incident to at least one vertex in S. 3 6 10 7 A E H B DI C F J G 6 16 10 7 23 9 10 9 33 total weight = 55 32


Download ppt "Final Exam Review Final exam will have the similar format and requirements as Mid-term exam: Closed book, no computer, no smartphone Calculator is Ok Final."

Similar presentations


Ads by Google