15 251 great theoretical ideas in computer science
play

15-251 Great Theoretical Ideas in Computer Science Lecture 20: - PowerPoint PPT Presentation

15-251 Great Theoretical Ideas in Computer Science Lecture 20: Randomized Algorithms November 5th, 2015 So far Formalization of computation/algorithm Computability / Uncomputability Computational complexity Graph theory and graph algorithms


  1. 15-251 Great Theoretical Ideas in Computer Science Lecture 20: Randomized Algorithms November 5th, 2015

  2. So far Formalization of computation/algorithm Computability / Uncomputability Computational complexity Graph theory and graph algorithms NP-completeness. Identifying intractable problems. Making use of intractable problems (in Social choice). Dealing with intractable problems: Approximation algs. Online algs.

  3. Next

  4. Randomness and the universe Does the universe have true randomness? Newtonian physics suggests that the universe evolves deterministically. Quantum physics says otherwise.

  5. Randomness and the universe Does the universe have true randomness? God does not play dice with the world. - Albert Einstein Einstein, don’t tell God what to do. - Niels Bohr

  6. Randomness and the universe Does the universe have true randomness? Even if it doesn’t, we can still model our uncertainty about things using probability. Randomness is an essential tool in modeling and analyzing nature. It also plays a key role in computer science.

  7. Randomness in computer science Randomized algorithms Does randomness speed up computation? Statistics via sampling e.g. election polls Nash equilibrium in Game Theory Nash equilibrium always exists if players can have probabilistic strategies. Cryptography A secret is only as good as the entropy/uncertainty in it.

  8. Randomness in computer science Randomized models for deterministic objects e.g. the www graph Quantum computing Randomness is inherent in quantum mechanics. Machine learning theory Data is generated by some probability distribution. Coding Theory Encode data to be able to deal with random noise. …

  9. Randomness and algorithms How can randomness be used in computation? Where can it come into the picture? Given some algorithm that solves a problem… - What if the input is chosen randomly? - What if the algorithm can make random choices?

  10. Randomness and algorithms How can randomness be used in computation? Where can it come into the picture? Given some algorithm that solves a problem… - What if the input is chosen randomly? - What if the algorithm can make random choices?

  11. Randomness and algorithms What is a randomized algorithm? A randomized algorithm is an algorithm that is allowed to flip a coin. (it can make decisions based on the output of the coin flip.) In 15-251: A randomized algorithm is an algorithm that is allowed to call: - RandInt(n) (we’ll assume these take time) O (1) - Bernoulli(p)

  12. Randomness and algorithms An Example def f(x): y = Bernoulli(0.5) if (y == 0): while (x > 0): print (“What up?”) x = x - 1 return x+y For a fixed input (e.g. x = 3) - the output can vary - the running time can vary

  13. Randomness and algorithms For a randomized algorithm, how should we: - measure its correctness? - measure its running time? If we require it to be - always correct, and - always runs in time O ( T ( n )) then we have a deterministic alg. with time compl. . O ( T ( n )) (Why?)

  14. Randomness and algorithms So for a randomized algorithm to be interesting: - it is not correct all the time, or - it doesn’t always run in time , O ( T ( n )) (It either gambles with correctness or running time.)

  15. Types of randomized algorithms Given an array with n elements (n even). A[1 … n]. Half of the array contains 0s, the other half contains 1s. Goal : Find an index that contains a 1. repeat 300 times: repeat : k = RandInt(n) k = RandInt(n) if A[k] = 1, return k if A[k] = 1, return k return “Failed” Doesn’t gamble with correctness Gambles with correctness Doesn’t gamble with run-time Gambles with run-time

  16. Types of randomized algorithms repeat 300 times: k = RandInt(n) if A[k] = 1, return k return “Failed” 1 Pr [failure] = 2 300 Worst-case running time: O (1) This is called a Monte Carlo algorithm. (gambles with correctness but not time)

  17. Types of randomized algorithms repeat : k = RandInt(n) if A[k] = 1, return k Pr [failure] = 0 Worst-case running time: can’t bound (could get super unlucky) Expected running time: O (1) (2 iterations) This is called a Las Vegas algorithm. (gambles with time but not correctness)

  18. Given an array with n elements (n even). A[1 … n]. Half of the array contains 0s, the other half contains 1s. Goal : Find an index that contains a 1. Correctness Run-time Deterministic always Ω ( n ) w.h.p. Monte Carlo O (1) O (1) w.h.p. always Las Vegas w.h.p. = with high probability

  19. Formal definition: Monte Carlo algorithm Let be a computational problem. f : Σ ∗ → Σ ∗ Suppose is a randomized algorithm such that: A Pr [ A ( x ) 6 = f ( x )]  ✏ ∀ x ∈ Σ ∗ , ∀ x ∈ Σ ∗ , # steps A ( x ) takes is ≤ T ( | x | ) . (no matter what the random choices are) Then we say is a -time Monte Carlo algorithm T ( n ) A for with probability of error. f ✏

  20. Formal definition: Las Vegas algorithm Let be a computational problem. f : Σ ∗ → Σ ∗ Suppose is a randomized algorithm such that: A ∀ x ∈ Σ ∗ , A ( x ) = f ( x ) ∀ x ∈ Σ ∗ , E [# steps A ( x ) takes] ≤ T ( | x | ) Then we say is a -time Las Vegas algorithm T ( n ) A for . f

  21. NEXT ON THE MENU Example of a Monte Carlo Algorithm: Min Cut Example of a Las Vegas Algorithm: Quicksort

  22. Example of a Monte Carlo Algorithm: Min Cut Gambles with correctness. Doesn’t gamble with running time.

  23. Cut Problems Max Cut Problem (Ryan O’Donnell’s favorite problem): Given a graph , G = ( V, E ) color the vertices red and blue so that the number of edges with two colors (e = { u , v }) is maximized. S V − S red blue

  24. Cut Problems Max Cut Problem (Ryan O’Donnell’s favorite problem): Given a graph , G = ( V, E ) find a non-empty subset such that S ⊂ V number of edges from to is maximized. S V − S S V − S size of the cut = # edges from to . S V − S

  25. Cut Problems Min Cut Problem (my favorite problem): Given a graph , G = ( V, E ) find a non-empty subset such that S ⊂ V number of edges from to is minimized . S V − S S V − S size of the cut = # edges from to . S V − S

  26. Contraction algorithm for min cut Let’s see a super simple randomized algorithm Min-Cut.

  27. Contraction algorithm for min cut a b e c d Size of min-cut: 2 Select an edge randomly: Green edge selected. Contract that edge.

  28. Contraction algorithm for min cut a b e d c Size of min-cut: 2 Select an edge randomly: Green edge selected. Contract that edge. (delete self loops)

  29. Contraction algorithm for min cut a b e d c Size of min-cut: 2 Select an edge randomly: Purple edge selected. Contract that edge. (delete self loops)

  30. Contraction algorithm for min cut a b e d c Size of min-cut: 2 Select an edge randomly: Purple edge selected. Contract that edge. (delete self loops)

  31. Contraction algorithm for min cut a b e d c Size of min-cut: 2 Select an edge randomly: Blue edge selected. Contract that edge. (delete self loops)

  32. Contraction algorithm for min cut a b e c d Size of min-cut: 2 Select an edge randomly: Blue edge selected. Contract that edge. (delete self loops)

  33. Contraction algorithm for min cut a b e c d Size of min-cut: 2 Select an edge randomly: Blue edge selected. Contract that edge. (delete self loops) When two vertices remain, you have your cut: {a, b, c, d} {e} size: 2

  34. Contraction algorithm for min cut a b e c d Size of min-cut: 2 Select an edge randomly: Green edge selected. Contract that edge. (delete self loops)

  35. Contraction algorithm for min cut a b e d c Size of min-cut: 2 Select an edge randomly: Green edge selected. Contract that edge. (delete self loops)

  36. Contraction algorithm for min cut a b e d c Size of min-cut: 2 Select an edge randomly: Yellow edge selected. Contract that edge. (delete self loops)

  37. Contraction algorithm for min cut a b e d c Size of min-cut: 2 Select an edge randomly: Yellow edge selected. Contract that edge. (delete self loops)

  38. Contraction algorithm for min cut a b e d c Size of min-cut: 2 Select an edge randomly: Red edge selected. Contract that edge. (delete self loops)

  39. Contraction algorithm for min cut a b e c d Size of min-cut: 2 Select an edge randomly: Red edge selected. Contract that edge. (delete self loops)

  40. Contraction algorithm for min cut a b e c d Size of min-cut: 2 Select an edge randomly: Red edge selected. Contract that edge. (delete self loops) When two vertices remain, you have your cut: {a} {b,c,d,e} size: 3

  41. contract contract contract contract G = G 0 − → G 1 − → G 2 − → G n − 2 → · · · − vertices vertices 2 n n − 2 iterations Observation: For any : A cut in of size corresponds exactly to k i G i a cut in of size . k G

  42. a b e G c d a b e G i d c

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend