the best algorithms are randomized algorithms

Download The Best Algorithms are Randomized Algorithms

Post on 23-Feb-2016

21 views

Category:

Documents

1 download

Embed Size (px)

DESCRIPTION

The Best Algorithms are Randomized Algorithms. N. Harvey C&O Dept. TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A A A A. Why do we randomize?. Reasons for Randomness. Fooling Adversaries Symmetry Breaking Searching a Haystack - PowerPoint PPT Presentation

TRANSCRIPT

The Best Algorithms are Randomized Algorithms

The Best Algorithms are Randomized AlgorithmsN. HarveyC&O DeptTexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAA1

Why do we randomize?Reasons for RandomnessFooling AdversariesSymmetry BreakingSearching a HaystackSampling huge sets...Picking PasswordsEncryption keys are randomly chosen

The Hallway Dance

Randomly go left or rightAfter a few twists you wont collide(usually!)

QuickSort1752391241910If I knew an approximate median, I could partition into 2 groups & recurseA random element is probably close to the medianLike searching for hay in a haystack1752391241910

Reasons for RandomnessFooling AdversariesSymmetry BreakingSearching a Haystack...

Another Adversary ExampleLinux 2.4.20 denial-of-service attackKernel uses a hash table to cache info about IP traffic flowsAdversary sends many IP packets that all have same hash valueHash table becomes linked list; Kernel very slowSolution: Randomized hash function

IP

Another Symmetry Breaking ExampleEthernet Media Access ControlTry to send packetIf collision detectedWait for a random delayRetry sending packethttp://picasaweb.google.com/tomatobasil

Another Haystack ExampleProblem: Find a point (x,y) that is not a zero of fIf f0 then, for randomly chosen (x,y), Pr[ f(x,y)=0 ] = 0Even over finite fields, Pr[ f(x,y)=0 ] is smallConsider the polynomial f(x,y)=(x-y2)(x2+2y+1)

Reasons for RandomnessFooling AdversariesSymmetry BreakingSearching a Haystack...Beauty: randomization often gives really cool algorithms!

Graph BasicsA graph is a collection of vertices and edgesEvery edge joins two verticesThe degree of a vertex is # edges attached to itGraph ConnectivityA connected graphA disconnected graphProblem: How many edges do you need to remove to make a graph disconnected?Graph ConnectivityProblem: How many edges do you need to remove to make a graph disconnected?

Connectivity is minimum # edges whose removal disconnects the graph

Observation:for every vertex v, degree(v) connectivityBecause removing all edges attached to vertex v disconnects the graphGraph ConnectivityProblem: How many edges do you need to remove to make a graph disconnected?

Connectivity is minimum # edges whose removal disconnects the graph

Useful in many applications:How many MFCF network cables must be cut to disrupt MCs internet connectivity?How many bombs can my oil pipelines withstand?Graph Connectivity ExampleRemoving red edges disconnects graphDefinition: A cut is a set of edges of the form { all edges with exactly one endpoint in S }where S is some set of vertices.Fact: min set of edges that disconnects graph is always a cutSAlgorithms for Graph ConnectivityGiven a graph, how to compute connectivity?Standard Approach: Network Flow TheoryFord-Fulkerson Algorithm computes an st min cut(minimum # edges to disconnect vertices s & t)Compute this value for all vertices s and t, then take the minimumGet min # edges to disconnect any two verticesCO 355 Approach:Compute st min cuts by ellipsoid method insteadNext: An amazing randomized approach

Algorithm OverviewInput: A haystackOutput: A needle (maybe)

While haystack not too smallPick a random handfulThrow it awayEnd WhileOutput whatever is leftEdge ContractionuvKey operation: contracting an edge uvDelete the edge uvCombine u & v into a single vertex wAny edge with endpoint u or v now ends at w

wEdge ContractionuvKey operation: contracting an edge uvDelete the edge uvCombine u & v into a single vertex wAny edge with endpoint u or v now ends at wThis can create parallel edgeswRandomized Algorithm for ConnectivityInput: A graphOutput: Minimum cut (maybe)

While graph has 2 vertices Not too smallPick an edge uv at random Random HandfulContract it Throw it awayEnd WhileOutput remaining edgesGraph Connectivity ExampleWe were lucky: Remaining edges are the min cutHow lucky must we be to find the min cut?Theorem (Karger 93): The probability that this algorithm finds a min cut is 1/(# vertices)2.But does the algorithm work?How lucky must we be to find the min cut?Theorem (Karger 93): The probability that this algorithm finds a min cut is 1/n2. (n = # vertices)

Fairly low success probability. Is this useful?Yes! Run the algorithm n2 times. Pr[ fails to find min cut ] (1-1/n2)n2 1/eSo algorithm succeeds with probability > 1/2Fix some min cut. Say it has k edges.If algorithm doesnt contract any edge in this cut, then the algorithm outputs this cutWhen contracting edge uv, both u & v are on same side of cutSo what is probability that this happens?While graph has 2 vertices Not too smallPick an edge uv at random Random HandfulContract it Throw it awayEnd WhileOutput remaining edgesProof of Main TheoremInitially there are n vertices.Claim 1: # edges in min cut=k every vertex has degree k total # edges nk/2Pr[random edge is in min cut] = # edges in min cut / total # edges k / (nk/2) = 2/nNow there are n-1 vertices.Claim 2: min cut in remaining graph is kWhy? Every cut in remaining graph is also a cut in original graph.So, Pr[ random edge is in min cut ] 2/(n-1)

In general, when there are i vertices left Pr[ random edge is in min cut ] 2/i

So Pr[ alg never contracts an edge in min cut ]

Input: Graph GOutput: min cut, with probability 1/2

For i=1,..,n2Start from GWhile graph has 2 verticesPick an edge uv at randomContract it End WhileLet Ei = { remaining edges }End ForOutput smallest EiFinal AlgorithmRunning time: O(mn2) (m = # edges, n = # vertices)With more beautiful ideas, improves to O(n2)How Many Min Cuts?Our analysis: for any particular min cut, Pr[ algorithm finds that min cut ] 1/n2

So suppose C1, C2, ..., Ct are all the min cuts1/n2 fraction of the time the algorithm finds C11/n2 fraction of the time the algorithm finds C2...1/n2 fraction of the time the algorithm finds CtThis is only possible if t n2Corollary: Any connected graph on n verticeshas n2 min cuts. (Actually, min cuts)

An n-cycle has exactly min cuts!

How Many Min Cuts?Corollary: Any connected graph on n vertices has min cuts.Is this optimal?

How Many Approximate Min Cuts?A similar analysis gives a nice generalization:

Theorem (Karger-Stein 96):Let G be a graph with min cut size k.Then # { cuts with k edges } n2.

No other proof of this theorem is known!Books

Motwani-Raghavan

Mitzenmacher-Upfal

Alon-SpencerClassesCS 466, CS 761 (still active?), C&O 738

Recommended

View more >