Presentation is loading. Please wait.

Presentation is loading. Please wait.

Section 11.4 Language Classes Based On Randomization

Similar presentations


Presentation on theme: "Section 11.4 Language Classes Based On Randomization"— Presentation transcript:

1 Section 11.4 Language Classes Based On Randomization

2 Introduction We shall look at a Turing Machine that models the generation of random numbers and the use of those numbers in algorithms. We shall also discuss two classes of languages, RP and ZPP, that use randomness and a polynomial time bound in different ways.

3 Section 11.4.1 Quicksort: A Randomized Algorithm
Given a list of elements, randomly select one element. Split the list into those above and those below the selected element. Recursively repeat the process on each new list. Put the new lists back together, resulting in a completely sorted list. Complexity Range: O(n log n) to O(n2).

4 Section 11.4.2 A Turing Machine Using Randomization
Use a multitape Turing Machine. The first tape contains the input. The second tape is called the random tape. When blanks are scanned, they are filled with randomly chosen 0’s and 1’s with a probability of ½ (“coin-flip”) and never changed. The third and subsequent tapes are blank scratch tapes.

5 Quicksort On A Randomized Turing Machine Step 1
Select Pivot (Random Aspect Of The Algorithm) The first tape contains the delineated sublist of length m. Use O(log m) new random bits from tape 2 to select a random number. Since the selected value may not be a power of 2, we may not be able to select every integer between 1 and m with equal probability. Take ┌2 log2 m┐ bits from tape 2, divide by m, and add 1. This yields a value between 1 and m with a probability close to 1/m.

6 Quicksort On A Randomized Turing Machine Steps 2 – 6
Place Pivot on Tape 3 Copy Values ≤ Pivot To Tape 4 (Sub-Sublist) Copy Values > Pivot To Tape 5 (Sub-Sublist) Copy The Sub-Sublists From Tapes 4 & 5 Back To The Space on Tape 1 That Held The Sublist, Placing A Marker Between The Two Sub-Sublists. If The Size of Either or Both Sub-Sublists > 1, Recursively Perform Quicksort On Those Sub-Sublists.

7 Section 11.4.3 Language of A Randomized Turing Machine
When considering the response to input w of a randomized TM M, all possible contents of the random tape must also be considered. Some of the strings on the random tape may result in an accept state while others a reject state. Any sequence of moves that leads to acceptance uses only a finite section of the infinite random tape. If m is the number of random tape cells scanned, the probability of what is seen there is 2-m.

8 Example of A Randomized Turing Machine
Transition Function of a Randomized Turing Function Each row corresponds to a state and each column to a pair of XY symbols where X is from the input tape and Y is from the random tape. The table entries qUVDE means the Turing Machine enters state q, writes U on the input tape, writes V on the random tape, moves the input head in direction D, and moves the random head in direction E.

9 Section 11.4.4 The Class RP (Random Polynomial)
For a language L to be in the Random Polynomial (RP) class, it must be accepted by a randomized TM M in the following sense: If w is not in L, then the probability that M accepts w is 0. If w is in L, then the probability that M accepts w is at least ½. There is a polynomial T(n) such that if input w is of length n, then all runs of M, regardless of the contents of the random tape, halt after at most T(n) steps. Points 1 and 2 define a randomized Turing Machine of a special type, sometimes called a Monte-Carlo algorithm. Regardless of running time we may say that a randomized Turing Machine is “Monte-Carlo” if it either accepts with probability 0 or accepts with probability at least 1/2, with nothing in between. Point 3 simply addresses the running time, which is independent of whether or not the Turing Machine is “Monte-Carlo”.

10 Example of RP Class Consider the language L that describes a graph. The question is whether or not L contains at least one triangle, i.e., that the graph contains at least three nodes, the pairs of which are connected by edges. Condition 1 – Probability of Acceptance = 0: There are a finite number choices of edge and node for the Turing Machine to determine if the graph has a triangle. If the graph has no triangle then the probability of acceptance is 0, meeting condition 1.

11 Example of RP Class - Continued
Condition 2 – Probability of Acceptance ≥ ½: Supposing the L has n nodes, e edges, and at least one triangle. The probability that the three nodes forming a triangle on any one of k samples is 1 – (1 – (3/(e(n – 2)))k For small values of x, a commonly used approximation of (1 – x)k is e–kx , where e is the base of the natural logrithms (2.718…). If we pick k such that kx = 1, then 1 – e–kx will be about 0.63, i.e., greater than ½. Thus k can be picked such that the probability of acceptance of a graph with a triangle is at least ½, meeting condition 2.

12 Example of RP Class - Continued
Condition 3 – Runs In Polynomial Time: Values e (edges) and n (nodes) are no greater than the input length, and k is no more than the square of the input length. Each sample is linear in the input length since it scans the input at most four times to pick a random edge, a node, and then to check for the presence of two more edges. Therefore the Turing Machine halts in at most cubic time of the input length and thus runs in polynomial time, meeting condition 3. Because L meets all three of the conditions, it is a member of the RP class.


Download ppt "Section 11.4 Language Classes Based On Randomization"

Similar presentations


Ads by Google