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
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) - PowerPoint PPT Presentation
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
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
Graham’s Scan (35.3)
O(nlogn)
Finding the Closest Pair(35.4)• Brute-force: O(n2)• 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.
Combine in D-a-C (35.4)• Subarray Y’ (y-sorted) of Y with points in 2 strip pY’ 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
left right
2
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)
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
NP-Completeness (36.4-5)
NPC
P
NP-hard
• P: yes and no in pt
• NP: yes in pt
• NPH NPC
NP
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
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
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
Set Cover• Given: a set X and a family F of subsets of X, F 2X, 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
a b c d
A = {a,b,c}, B = {c,d}
B
Intermediate Classes
NPC
NP-hard
P NP
Dense Set Coveris 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
– 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
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)}
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– e1, e2, ..., ek - edges chosen by 2-VC– the optimal vertex cover has 1 endpoint of ei– 2-VC outputs 2k vertices while optimum k
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
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