Presentation is loading. Please wait.

Presentation is loading. Please wait.

Convex Hull(35.3) Convex Hull, CH(X), is the smallest convex polygon containing all points from X, |X|=n Different methods: –incremental: moving from left.

Similar presentations


Presentation on theme: "Convex Hull(35.3) Convex Hull, CH(X), is the smallest convex polygon containing all points from X, |X|=n Different methods: –incremental: moving from left."— Presentation transcript:

1 Convex Hull(35.3) Convex Hull, CH(X), is the smallest convex polygon containing all points from X, |X|=n Different methods: –incremental: moving from left to right updates CH(x1..xi). the runtime O(nlogn) –divide-and-conquer divides into two subsets left and right in O(n), then combine into one convex hull in O(n) –prune-and-search O(n logh), where h is the # points in CH uses pruning as for finding median to find upper chain

2 Graham’s Scan (35.3) O(nlogn)

3 Finding the Closest Pair(35.4) Brute-force: O(n 2 ) Divide-and-conquer algorithm with recurrence T(n)=2T(n/2)+O(n) Divide: divide into almost equal parts by a vertical line which divides given x-sorted array X into 2 sorted subarrays Conquer: Recursively find the closest pair in each half of X. Let  = min{  left,  right } Combine: The closest pair is either in distance  or a pair of points from different halves.

4 Combine in D-a-C (35.4) Subarray Y’ (y-sorted) of Y with points in 2  strip  p  Y’ find all in Y’ which are closer than in  –no more than 8 in   2  rectangle –no more than 7 points can be closer than in  If the closest in the strip closer then it is the answer 22  left right 22 

5 Voronoi Graph Voronoi region Vor(p) (p in set S) –the set of points on the plane that are closer to p than to any othe rpoint in S Voronoi Graph VOR(S) –dual to voronoi region graph –two points are adjacent if their voronoi regions have common contiguous boundary (segment)

6 Voronoi Graph Voronoi Graph in the rectilinear plane Rectilinear distance: p = (x, y); p’=(x’,y’) a b c bc ac ab Voronoi region of b

7 NP-Completeness (36.4-5) NPC P NP-hard P: yes and no in pt NP: yes in pt NPH  NPC NP

8 Independent Set Independent set in a graph G: pairwise nonadjacent vertices Max Independent Set is NPC Is there independent set of size k? –Construct a graph G: literal -> vertex two vertices are adjacent iff –they are in the same clause –they are negations of each other –3-CNF with k clauses is satisfiable iff G has independent k-set assign 1’s to literals-vertices of independent set Example: f = (x+z+y’) & (x’+z’+a) & (a’+x+y) x z y’ x’ z’ a a’ x y x, z’, y independent F is satisfiable: f = 1 if x = z’ = y = 1

9 MAX Clique Max Clique (MC): –Find the maximum number of pairwise adjacent vertices MC is in NP –for the answer yes there is certificate of polynomial length = clique which can be checked in polynomial time MC is in NPC –Polynomial time reduction from MIS: For any graph G any independent set in G 1-1 corresponds to clique in the complement graph G’ red independent set red clique G Complement G’ noedge  edge edge  noedge

10 Minimum Vertex Cover Vertex Cover: –the set of vertices which has at least one endpoint in each edge Minimum Vertex Cover (MVC): –the set of vertices which has at least one endpoint in each edge MIN Vertex Cover is NPC –If C is vertex cover, then V - C is an independent set red independent set blue vertex cover

11 Set Cover Given: a set X and a family F of subsets of X, F  2 X, s.t. X covered by F Find : subfamily G of F such that G covers X and |G| is minimize Set Cover is NPC –reduction from Vertex Covert Graph representation: red elements of ground set X blue subsets in family F edge between set A  F and element x  X means x  A A abc d A = {a,b,c}, B = {c,d} B

12 Intermediate Classes NPC NP-hard P  NP  Dense Set Cover is NP but not in P neither in NPC Dense Set Cover: Each element of X belongs to at least half of all sets in F

13 Runtime Complexity Classes Runtime order: –constant –almost constant –logarithmic –sublinear –linear –pseudolinear –quadratic –polynomial –subexponential –exponential –superexponential Example –adding an element in a queue/stack –inverse Ackerman function = O(loglog…log n) n times –extracting minimum from binary heap –n 1/2 –traversing binary search tree, list –O(n log n) sorting n numbers, closest pair, MST, Dijkstra shortest paths –adding two n  n matrices – e n ^ (1/2) – e n,, n! –Ackerman function 2. 2 n times

14 Hamiltonian Cycle and TSP Hamiltonian Cycle: –given an undirected graph G –find a tour which visits each point exactly once Traveling Salesperson Problem –given a positive weighted undirected graph G (with triangle inequality = can make shortcuts) –find a shortest tour which visits all the vertices HC and TSP are NPC NPC problems: SP, ISP, MCP, VCP, SCP, HC, TSP

15 Approximation Algorithms (37.0) When problem is in NPC try to find approximate solution in polynomial-time Performance Bound = Approximation Ratio (APR) (worst-case performance) –Let I be an instance of a minimization problem –Let OPT(I) be cost of the minimum solution for instance I –Let ALG(I) be cost of solution for instance I given by approximate algorithm ALG APR(ALG) = max I {ALG(I) / OPT(I)} APR for maximization problem = max I {ALG(I) / OPT(I)}

16 Vertex Cover Problem (37.1) Find the least number of vertices covering all edges Greedy Algorithm: –while there are edges add the vertex of maximum degree delete all covered edges 2-VC Algorithm: –while there are edges add the both ends of an edge delete all covered edges APR of 2-VC is at most 2 –e 1, e 2,..., e k - edges chosen by 2-VC –the optimal vertex cover has  1 endpoint of e i –2-VC outputs 2k vertices while optimum  k

17 2-approximation TSP (37.2) Given a graph G with positive weights Find a shortest tour which visits all vertices Triangle inequality w(a,b) + w(b,c)  w(a,c) 2-MST algorithm: –Find the minimum spanning tree MST(G) –Take MST(G) twice: T = 2  MST(G) –The graph T is Eulerian - we can traverse it visiting each edge exactly once –Make shortcuts APR of 2-MST is at most 2 –MST weight  weight of optimum tour any tour is a spanning tree, MST is the minimum

18 3/2-approximation TSP (Manber) Matching Problem (in P) –given weighted complete (all edges) graph with even # vertecies –find a matching (pairwise disjoint edges) of minimum weight Christofides’s Algorithm (ChA) –find MST(G) –for odd degree vertices find minimum matching M –output shortcutted T = MST(G) + M APR of ChA is at most 3/2 –|MST|  OPT –|M|  OPT/2 –|T|  (3/2) OPT odd

19 3/2-approximation TSP Christofides’s Algorithm (ChA) –find MST(G) –for odd degree vertices find minimum matching M –output shortcutted T = MST(G) + M The worst case for Christofides heuristic in Euclidean plane: 1 1 1 1234… k k+1k+2… 2k-1k+3 - Minimum Spanning Tree length = 2k - 2 - Minimum Matching of 2 odd degree nodes = k - 1 - Christofides heuristic length = 3k - 3 - Optimal tour length = 2k - 1 - Approximation Ratio of Christofides = 3/2-1/(k-1/2)

20 Non-approximable TSP (37.2) Approximating TSP w/o triangle inequality is NPC –any c-approximation algorithm can solve Hamiltonian Cycle Problem in polynomial time Take an instance of HCP = graph G Assign weight 0 to any edge of G Complete G up to complete graph G’ Assign weight 1 to each new edge c-approximate tour can use only 0-edges - so it gives Hamiltonian cycle of G

21 Steiner Tree Problem Given: A set S of points in the plane = terminals Find: Minimum-cost tree spanning S = minimum Steiner tree 1 1 Cost = 2 Steiner Point Cost =  3 1 Terminals 1 1 Euclidean metric 1 1 1 1 1 1 1 1 1 1 Cost = 6Cost = 4 Rectilinear metric

22 Steiner Tree Problem in Graphs Given a graph G=(V,E,cost) and terminals S in V Find minimum-cost tree spanning all terminals MST algorithm (does not use Steiner points): –find G(S) = complete graph on terminals edge cost = shortest path cost –find T(S) = MST of G(S) –replace each edge of T(S) with the path in G –output T(S)

23 MST -Heuristic Theorem: MST-heuristic is a 2-approximation in graphs Proof: MST < Shortcut Tour  Tour = 2 OPTIMUM

24 Approximation Ratios Euclidean Steiner Tree Problem – approximation ratio = 2/  3 Rectilinear Steiner Tree Problem –approximation ratio = 3/2 Steiner Tree Problem in graphs –approximation ratio = 2 Steiner Point Opt Cost = k 1 2 3 k 5 4 MST Cost = 2k-2 Approximation ratio = 2-2/k  2

25 The Set Cover Problem Sets A i cover a set X if X is a union of A i Weighted Set Cover Problem Given: –A finite set X (the ground set X) –A family of F of subsets of X, with weights w: F   + Find: –sets S  F, such that S covers X, X =  {s | s  S} and S has the minimum total weight  {w(s) | s  S} If w(s) =1 (unweighted), then minimum # of sets

26 Greedy Algorithm for SCP Greedy Algorithm: –While X is not empty find s  F minimizing w(s) / |s  X| X = X - s C = C + s –Return C 6 345 2 1

27 Analysis of Greedy Algorithm Th: APR of the Greedy Algorithm is at most 1+ln k Proof:

28 Approximation Complexity Approximation algorithm = polynomial time approximation algorithm PTAS = a series of approximation algorithms s.t. for any  > 0 there is pt (1+  )-approximation –There is PTAS fro subset sum Remarkable progress in 90’s (assuming P  NP). –No PTAS for Vertex Cover –No clog k-approximation for Set Cover for k < 1 k is the size of the ground set X –No n 1-  approximation for Independent Set n is the number of vertices


Download ppt "Convex Hull(35.3) Convex Hull, CH(X), is the smallest convex polygon containing all points from X, |X|=n Different methods: –incremental: moving from left."

Similar presentations


Ads by Google