Randomized Algorithms Randomized Algorithms Two Types of Randomized Algorithms Two Types of Randomized Algorithms and and Some Complexity Classes Some Complexity Classes Speaker: Chuang-Chieh Lin Advisor: Professor Maw-Shang Chang National Chung Cheng University 2006/9/20 2006/9/20
References References � Professor Hsueh-I Lu’s slides. � Randomized Algorithms , Rajeev Motwani and Prabhakar Raghavan. � Probability and Computing - Randomized Algorithms and Probabilistic Analysis , Michael Mitzenmacher and Eli Upfal. 2006/9/20 2 2006/9/20 2 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
Outline Outline � Las Vegas algorithms and Monte Carlo algorithms � RAMs and Turing machines � Complexity classes – P , NP , RP , ZPP , BPP and their complementary classes – Open problems 2006/9/20 3 2006/9/20 3 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
Las Vegas vs. Monte Carlo Las Vegas vs. Monte Carlo � Las Vegas algorithms � Monte Carlo algorithms – Always produces a – Allow a small (correct/optimal) probability for solution. outputting an incorrect/non-optimal – Like RandQS. solution. – Like RandMC. – The name is by von Neumann. 2006/9/20 4 2006/9/20 4 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
Las Vegas Algorithms Las Vegas Algorithms � For example, RandQS is a Las Vegas algorithm. � A Las Vegas always gives the correct solution � The only variation from one run to another is its running time, whose distribution we study. 2006/9/20 5 2006/9/20 5 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
Randomized quicksort quicksort Randomized algorithm RandQS( X ) { if X is empty then randomization return; select x uniformly at random from X ; let Y = { y ∈ X | y < x } ; let Z = { z ∈ X | z > x } ; call RandQS( Y ); print x ; call RandQS( Z ); } 2006/9/20 6 2006/9/20 6 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
An illustration An illustration 4 2 7 8 1 9 3 6 5 4 2 1 5 7 8 9 6 3 1 2 4 3 6 7 8 9 1 3 4 6 8 9 9 3 2006/9/20 7 2006/9/20 7 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
2 Questions for RandQS RandQS 2 Questions for Is RandQS correct? � – That is, does RandQS “always” output a sorted list of X ? What is the time complexity of RandQS? � – Due to the randomization for selecting x , the running time for RandQS becomes a random variable. – We are interested in the expected time complexity for RandQS. 2006/9/20 8 2006/9/20 8 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
Monte Carlo algorithms Monte Carlo algorithms � For example, RandEC (the randomized minimum-cut algorithm we have discussed) is a Monte Carlo algorithm. � A Monte Carlo algorithm may sometimes produce a solution that is incorrect. � For decision problems, there are two kinds of Monte Carlo algorithms: – those with one-sided error – those with two-sided error 2006/9/20 9 2006/9/20 9 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
Which is better? Which is better? � The answer depends on the application. � A Las Vegas algorithm is by definition a Monte Carlo algorithm with error probability 0. � Actually, we can derive a Las Vegas algorithm A from a Monte Carlo algorithm B by repeated running B until we get a correct answer. 2006/9/20 10 2006/9/20 10 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
Computation model Computation model � Throughout this talk, we use the Turing machine model to discuss complexity theory issues. � As is common, we switch to the RAM (random access machine) as the model of computation when describing and analyzing algorithms. 2006/9/20 11 2006/9/20 11 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
Computation model (cont’ ’d) d) Computation model (cont � For simplicity, we will work with the general unit-cost RAM model. � In unit-cost RAM model, each instruction can be performed in one time step. 2006/9/20 12 2006/9/20 12 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
You can refer to any computation theory textbook Deterministic TM Deterministic TM to for more details here. � A deterministic Turing machine is a quadruple M = ( S , ∑ , δ , s ). – Here S is a finite set of states, of which s ∈ S is the machine’s initial state. – ∑ : a finite set of symbols (this set includes special symbols BLANK and FIRST). – δ : the transition function of the Turing machine, mapping S × ∑ to (S ∪ {HALT, YES, NO}) × ∑ × { ← , → , STAY}. � The machine has three states: HALT (the halting state), YES (the accepting state), and NO (the rejecting state) (these are states, but formally not in S .) 2006/9/20 13 2006/9/20 13 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
A Turing machine with one tape A Turing machine with one tape B state \ symbol 0 1 t ( s, B , → ) s ( s, 0 , → ) ( s, 1 , → ) ( q, t , ← ) ( h, B , → ) q ( q 0 , t , → ) ( q 1 , t , → ) ( q, t , − ) ( h, B , → ) q 0 ( s, 0 , ← ) ( s, 0 , ← ) ( s, 0 , ← ) ( h, B , → ) q 1 ( s, 1 , ← ) ( s, 1 , ← ) ( s, 1 , ← ) × × × × h Q: What does this Turing B machine do? 0 1 0 0 2006/9/20 14 2006/9/20 14 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
A Turing machine with one tape A Turing machine with one tape B state \ symbol 0 1 t ( s, B , → ) s ( s, 0 , → ) ( s, 1 , → ) ( q, t , ← ) ( h, B , → ) q ( q 0 , t , → ) ( q 1 , t , → ) ( q, t , − ) ( h, B , → ) q 0 ( s, 0 , ← ) ( s, 0 , ← ) ( s, 0 , ← ) ( h, B , → ) q 1 ( s, 1 , ← ) ( s, 1 , ← ) ( s, 1 , ← ) × × × × h Q: What does this Turing B machine do? 0 1 0 2006/9/20 15 2006/9/20 15 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
A Turing machine with one tape A Turing machine with one tape B state \ symbol 0 1 t ( s, B , → ) s ( s, 0 , → ) ( s, 1 , → ) ( q, t , ← ) ( h, B , → ) q ( q 0 , t , → ) ( q 1 , t , → ) ( q, t , − ) ( h, B , → ) q 0 ( s, 0 , ← ) ( s, 0 , ← ) ( s, 0 , ← ) ( h, B , → ) q 1 ( s, 1 , ← ) ( s, 1 , ← ) ( s, 1 , ← ) × × × × h Q: What does this Turing B machine do? 0 1 0 2006/9/20 16 2006/9/20 16 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
A Turing machine with one tape A Turing machine with one tape B state \ symbol 0 1 t ( s, B , → ) s ( s, 0 , → ) ( s, 1 , → ) ( q, t , ← ) ( h, B , → ) q ( q 0 , t , → ) ( q 1 , t , → ) ( q, t , − ) ( h, B , → ) q 0 ( s, 0 , ← ) ( s, 0 , ← ) ( s, 0 , ← ) ( h, B , → ) q 1 ( s, 1 , ← ) ( s, 1 , ← ) ( s, 1 , ← ) × × × × h Q: What does this Turing B machine do? 0 1 0 2006/9/20 17 2006/9/20 17 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
A Turing machine with one tape A Turing machine with one tape B state \ symbol 0 1 t ( s, B , → ) s ( s, 0 , → ) ( s, 1 , → ) ( q, t , ← ) ( h, B , → ) q ( q 0 , t , → ) ( q 1 , t , → ) ( q, t , − ) ( h, B , → ) q 0 ( s, 0 , ← ) ( s, 0 , ← ) ( s, 0 , ← ) ( h, B , → ) q 1 ( s, 1 , ← ) ( s, 1 , ← ) ( s, 1 , ← ) × × × × h Q: What does this Turing B machine do? 0 1 0 2006/9/20 18 2006/9/20 18 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
A Turing machine with one tape A Turing machine with one tape B state \ symbol 0 1 t ( s, B , → ) s ( s, 0 , → ) ( s, 1 , → ) ( q, t , ← ) ( h, B , → ) q ( q 0 , t , → ) ( q 1 , t , → ) ( q, t , − ) ( h, B , → ) q 0 ( s, 0 , ← ) ( s, 0 , ← ) ( s, 0 , ← ) ( h, B , → ) q 1 ( s, 1 , ← ) ( s, 1 , ← ) ( s, 1 , ← ) × × × × h Q: What does this Turing B machine do? 0 1 0 2006/9/20 19 2006/9/20 19 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
A Turing machine with one tape A Turing machine with one tape B state \ symbol 0 1 t ( s, B , → ) s ( s, 0 , → ) ( s, 1 , → ) ( q, t , ← ) ( h, B , → ) q ( q 0 , t , → ) ( q 1 , t , → ) ( q, t , − ) ( h, B , → ) q 0 ( s, 0 , ← ) ( s, 0 , ← ) ( s, 0 , ← ) ( h, B , → ) q 1 ( s, 1 , ← ) ( s, 1 , ← ) ( s, 1 , ← ) × × × × h Q: What does this Turing B machine do? 0 1 0 2006/9/20 20 2006/9/20 20 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
A probabilistic TM A probabilistic TM � A probabilistic Turing machine is a (nondeterministic) Turing machine augmented with the ability to generate an unbiased coin flip in one step. � It corresponds to a randomized algorithm. 2006/9/20 21 2006/9/20 21 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
A probabilistic TM (cont’ ’d) d) A probabilistic TM (cont � On any input x , a probabilistic Turing machine accepts x with some probability, and we study this probability. 2006/9/20 22 2006/9/20 22 Computation Theory Lab, CSIE, CCU, Taiwan Computation Theory Lab, CSIE, CCU, Taiwan
Recommend
More recommend