• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Randomized Algorithm
 

Randomized Algorithm

on

  • 9,159 views

This seminar was presented by Ashish Kumar...

This seminar was presented by Ashish Kumar
A randomized algorithm is defined as an algorithm that typically
uses the random bits as an auxiliary input to guide its behavior. It achievs
good performance in the "average case". Formally, the algorithm's
performance will be a random variable determined by the random bits,
with (hopefully) good expected value. The "worst case" is typically so
unlikely to occur that it can be ignored. First and foremost reason for
using randomized algorithms is simplicity.

Statistics

Views

Total Views
9,159
Views on SlideShare
9,101
Embed Views
58

Actions

Likes
0
Downloads
352
Comments
2

2 Embeds 58

http://www.aliencoders.com 57
http://aliencoders.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Randomized Algorithm Randomized Algorithm Document Transcript

    • Seminar Report OnRANDOMIZED ALGORITHM Submitted by ASHISH KUMAR In partial fulfillment of the requirements for the Degree of Bachelor of Technology (B. Tech) in Computer Science and Engineering DIVISION OF COMPUTER ENGINEERING SCHOOL OF ENGINEERINGCOCHIN UNIVERSTY OF SCIENCE AND TECHNOLOGY COCHIN-682022 SEPTEMBER 2009
    • COCHIN UNIVERSTY OF SCIENCE AND TECHNOLOGY DIVISION OF COMPUTER ENGINEERING CENTRE FOR ENGINEERING STUDIES COCHIN-682022 Certificate Certified that this is a bonafide record of the seminar entitled “RANDOMIZED ALGORITHM” taken by ASHISH KUMARof the VIIth semester ,Computer Science and Engineering in the year2009 in partial fulfillment of the requirements to the award of DegreeBachelor of Technology in Computer Science and Engineering of CochinUniversity of Science and Technology.Ms. Ramyamol Dr. David PeterSeminar Guide Head of the DivisionPlace: Kochi-22Date: 15.09.2009
    • ACKNOWLEDGEMENT I take this occasion to thank God, Almighty for blessing me withhis grace and taking my endeavor to a successful culmination. I extendmy sincere and heartfelt thanks to my esteemed guide, Ms. Ramyamolfor providing me with the right guidance and advice at the crucialjunctures and for showing me the right way. I extend my sincere thanks toour respected head of the division Mr. David Peter, for allowing me touse the facilities available. I would like to thank the other facultymembers also, at this occasion. Last but not least, I would like to thankfriends for the support and encouragement they have given us during thecourse of my work. Ashish Kumar i
    • ABSTRACT A randomized algorithm is defined as an algorithm that typicallyuses the random bits as an auxiliary input to guide its behavior. It achievsgood performance in the "average case". Formally, the algorithmsperformance will be a random variable determined by the random bits,with (hopefully) good expected value. The "worst case" is typically sounlikely to occur that it can be ignored. First and foremost reason forusing randomized algorithms is simplicity. An easy randomizedalgorithm can match the performance of a deterministic algorithm. Forsome problems, the best-known randomized algorithms are faster than thebest-known deterministic algorithms. This is achieved by requiring thatthe correct answer be found only with high probability or that thealgorithm should run in expected polynomial time. This means that therandomized algorithm may not find a correct answer in some cases ormay take very long time.Two types of Randomized Algorithms:1. Las Vegas Algorithm2. Monte Carlo Algorithm Las Vegas Algorithm: The randomized algorithm always outputsthe correct answer, it is just that there is a small probability of takinglong to execute. Monte Carlo Algorithm: The algorithm always completes quickly,but allow a small probability of error. Quicksort is probably the mostfamiliar "real-world" algorithm in which randomness is very useful. Thedeterministic version of this algorithm requires O(n2) time to sort nnumbers for some degenerate inputs -- such as the array elements beingalready in sorted order! However, if the algorithm randomly permutes ii
    • elements before starting, it finishes in O(n log n) time with a highprobability, for any input. The difference between the two is crucialwhen sorting large data sets. iii
    • LIST OF FIGURES8. Min Cut………………………. ….……………………………..…20 iv
    • TABLE OF CONTENTSACKNOWLEGMENT………………………………………………………….....…iABSTRACT……………………………………………………………………….....iiLIST OF FIGURES…………………………………………………….…………....ivTABLE OF CONTENTS…………………………………………………………......v1. INTRODUCTION………………………………..........………………..…............12. TYPES OF ALGORITHM……………………………….............…….......……...13. RANDOMIZED ALGORITHM 3.1Random Number Generation...………………………………..….…..…...5 3.2 True Random number Vs pseudorandom number………....…….…….....5 3.3 Generation Method 3.3.1 Physical Method..........................................................................6 3.3.2 Computational Method………………………………………...7 3.3.3 Generation From a Probability Distribution...............................94. DETERMINISTIC ALGORITHM……..……………………..….………….......105. RANDOMIZED ALGORITHM……………………………….…...…………....10 5.1 Why Randomized Algorithm…………………………………………...116. LAS VEGAS & MONTE CARLO 6.1 Las Vegas Algorithm…………….....………………………….….….....12 6.2 Monte Carlo Algorithm………..…………………………………..…....127. RANDOMIZED QUICK SORT 7.1 Traditional Quicksort……………………………………………………14 7.1 Randomized Quicksort……………..........................................................158. RANDOMIZED MIN-CUT ALGORITHM..........................................................189. COMPLEXITY CLASSES ....................................................................................2210. ADVANTAGES…………...................................................................................2511. DISADVANTAGES……………………………………………………………2612. SCOPE…………………………………………………………………………..2713. CONCLUSION…………………………………………………………………2814. BIBLIOGRAPHY………………………………………………………………29 v
    • vi
    • Randomized Algorithm Seminar Report ‘09 1. INTRODUCTION An algorithm is any well-defined computational procedure that takessome values, or set of values as input and produces some values or set ofvalues as output. An algorithm is thus a sequence of computational steps thattransform the input into the output. A problem can be represented as a tuple,problem (instances, solutions). Where instances are the inputs to the problemand solutions are the outputs to the problem. To solve a problem we can usedifferent algorithms. These algorithms differ dramatically in their efficiency. A randomized algorithm is defined as an algorithm that typically usesthe random bits as an auxiliary input to guide its behavior. It achieves goodperformance in the "average case". 2. TYPES OF ALGORITHMAlgorithm classification Algorithms that use a similar problem-solving approach can begrouped together. This classification scheme is neither exhaustive nor disjoint.The purpose is not to be able to classify an algorithm as one type or another,but to highlight the various ways in which a problem can be attacked.A short list of categories Algorithm types considered include: – Simple recursive algorithms – Backtracking algorithms – Divide and conquer algorithms – Dynamic programming algorithms – Greedy algorithms – Branch and bound algorithmsDivision of Computer Engineering 1
    • Randomized Algorithm Seminar Report ‘09 – Brute force algorithms – Randomized algorithmsSimple recursive algorithms A simple recursive algorithm consist of following steps: – Solves the base cases directly. – Recurs with a simpler sub problem. – Does some extra work to convert the solution to the simpler sub problem into a solution to the given problem. We call these “simple” because several of the other algorithm types are inherently recursive.Backtracking algorithms Backtracking algorithms are based on a depth-first recursive searchA backtracking algorithm consists of following steps: – Tests to see if a solution has been found, and if so, returns it; otherwise. – For each choice that can be made at this point, • Make that choice • Recur • If the recursion returns a solution, return it – If no choices remain, return failure.Division of Computer Engineering 2
    • Randomized Algorithm Seminar Report ‘09Divide and Conquer A divide and conquer algorithm consists of two parts: – Divide the problem into smaller sub problems of the same type, and solve these sub problems recursively – Combine the solutions to the subproblems into a solution to the original problem Traditionally, an algorithm is only called divide and conquer if itcontains two or more recursive calls.Dynamic programming algorithms A dynamic programming algorithm remembers past results anduses them to find new results. Dynamic programming is generally used foroptimization problems. – Multiple solutions exist, need to find the “best” one – Requires “optimal substructure” and “overlapping subproblems” • Optimal substructure: Optimal solution contains optimal solutions to subproblems • Overlapping subproblems: Solutions to subproblems can be stored and reused in a bottom-up fashion • This differs from Divide and Conquer, where subproblems generally need not overlap.Division of Computer Engineering 3
    • Randomized Algorithm Seminar Report ‘09Greedy algorithms An optimization problem is one in which you want to find, not just asolution, but the best solution A “greedy algorithm” sometimes works well foroptimization problems. A greedy algorithm works in phases: At each phase: – You take the best you can get right now, without regard for future consequences. – You hope that by choosing a local optimum at each step, you will end up at a global optimum.Brute force algorithm A brute force algorithm simply tries all possibilities until a satisfactorysolution is found Such an algorithm can be: Optimizing: Find the best solution. This may require finding allsolutions, or if a value for the best solution is known, it may stop when anybest solution is found.Example: Finding the best path for a travelling salesman. Satisficing: Stop as soon as a solution is found that is good enoughExample: Finding a travelling salesman path that is within 10% of optimal.Division of Computer Engineering 4
    • Randomized Algorithm Seminar Report ‘09 3. RANDOM NUMBER3.1. Random number generation A random number generator (often abbreviated as RNG) is acomputational or physical device designed to generate a sequence of numbersor symbols that lack any pattern, i.e. appear random. Hardware-based systemsfor random number generation are widely used, but often fall short of thisgoal, though they may meet some of the statistical tests for randomnessintended to ensure that they do not have any easily discernible patterns.Methods for generating random results have existed since ancient times,including dice, coin flipping, the shuffling of playing cards, the use of yarrowstalks (by divination) in the I Ching, and many other techniques. The many applications of randomness have led to many differentmethods for generating random data. These methods may vary as to howunpredictable or statistically random they are, and how quickly they cangenerate random numbers. Before the advent of computational random number generators,generating large amounts of sufficiently random numbers (important instatistics) required a lot of work. Results would sometimes be collected anddistributed as random number tables. A growing number of government-run lotteries, and lottery games, areusing RNGs instead of more traditional drawing methods, such as using ping-pong or rubber balls.3.2. "True" random numbers vs. pseudorandom numbers There are two principal methods used to generate random numbers.One measures some physical phenomenon that is expected to be random andthen compensates for possible biases in the measurement process. The otheruses computational algorithms that produce long sequences of apparentlyDivision of Computer Engineering 5
    • Randomized Algorithm Seminar Report ‘09random results, which are in fact completely determined by a shorter initialvalue, known as a seed or key. The latter type are often called pseudorandomnumber generators. A "random number generator" based solely on deterministiccomputation cannot be regarded as a "true" random number generator, sinceits output is inherently predictable. How to distinguish a "true" randomnumber from the output of a pseudo-random number generator is a verydifficult problem. However, carefully chosen pseudo-random numbergenerators can be used instead of true random numbers in many applications.Rigorous statistical analysis of the output is often needed to have confidencein the algorithm.3.3. Generation methods3.3.1. Physical methods There is general agreement that, if there are such things as "true"random numbers, they are most likely to be found by looking at physicalprocesses which are, as far as is known, unpredictable. The earliest methodsfor generating random numbers — dice, coin flipping, roulette wheels — arestill used today, mainly in games and gambling as they tend to be too slow forapplications in statistics and cryptography. The generation of true random numbers outside the computerenvironment is based on the theory of entropy. A physical random numbergenerator can be based on an essentially random atomic or subatomic physicalphenomenon whose unpredictability can be traced to the laws of quantummechanics. Sources of entropy include radioactive decay, thermal noise, shotnoise, clock drift, and atmospheric conditions. Various imaginative ways of collecting this entropic information havebeen devised. Atari 8-bit computers used electronic noise from an analogDivision of Computer Engineering 6
    • Randomized Algorithm Seminar Report ‘09circuit to generate true random numbers. One common technique is to run ahash function against a frame of a video stream from an unpredictable source.Lavarand used this technique with images of a number of lava lamps. LithiumTechnologies uses a camera pointed at the sky on a windy and cloudy day.HotBits measures radioactive decay with GM tubes, while Random.org usesvariations in the amplitude of atmospheric noise recorded with a normal radio. Some physical phenomena, such as thermal noise in Zener diodesappear to be truly random and can be used as the basis for hardware randomnumber generators. However, many mechanical phenomena featureasymmetries and systematic biases that make their outcomes not truly random.The many successful attempts to exploit such phenomena by gamblers,especially in roulette and blackjack are testimony to these effects. Another common entropy source is the behavior of human users of thesystem, if such users exist. While humans are not considered good randomnessgenerators upon request, they generate random behavior quite well in thecontext of playing mixed strategy games. Some security-related computersoftware requires the user to input a lengthy string of mouse movements orkeyboard input to add a certain degree of randomness to computationalpseudo-random number generation.[3.3.2. Computational methods Pseudo-random number generators (PRNGs) are algorithms that canautomatically create long runs (for example, millions of numbers long) withgood random properties but eventually the sequence repeats (or the memoryusage grows without bound). One of the most common PRNG is the linearcongruential generator, which uses the recurrenceDivision of Computer Engineering 7
    • Randomized Algorithm Seminar Report ‘09to generate numbers. The maximum number of numbers the formula canproduce is the modulus, m. To avoid certain non-random properties of a singlelinear congruential generator, several such random number generators withslightly different values of the multiplier coeffient a are typically used inparallel, with a "master" random number generator that selects from amongthe several different generators. A simple pen-and-paper method for generating random numbers isthe so-called middle square method suggested by John Von Neumann. Whilesimple to implement, its output is of poor quality. Most computer programming languages include functions or libraryroutines that purport to be random number generators. They are often designedto provide a random byte or word, or a floating point number uniformlydistributed between 0 and 1. Such library functions often have poor statistical properties and somewill repeat patterns after only tens of thousands of trials. They are ofteninitialized using a computers real time clock as the seed. These functions mayprovide enough randomness for certain tasks (for example video games) butare unsuitable where high-quality randomness is required, such as incryptographic applications, statistics or numerical analysis. Much higherquality random number sources are available on most operating systems; forexample /dev/random on various BSD flavors, Linux, Mac OS X, IRIX, andSolaris, or CryptGenRandom for Microsoft Windows. An example of a simple random number generator that iscomputationally fast, has good (albeit not cryptographically strong)randomness properties, is (note that this example is not thread safe):Division of Computer Engineering 8
    • Randomized Algorithm Seminar Report ‘09m_w = <choose-initializer>;m_z = <choose-initializer>;uint get_random(){ m_z = 36969 * (m_z & 65535) + (m_z >> 16); m_w = 18000 * (m_w & 65535) + (m_w >> 16); return (m_z << 16) + m_w; /* 32-bit result */}3.3.3. Generation from a probability distribution There are a couple of methods to generate a random number based on aprobability density function. These methods involve transforming a uniformrandom number in some way. Because of this, these methods work equallywell in generating both pseudo-random and true random numbers. Onemethod, called the inversion method, involves integrating up to an area greaterthan or equal to the random number (which should be generated between 0and 1 for proper distributions). A second method, called the acceptance-rejection method, involves choosing an x and y value and testing whether thefunction of x is greater than the y value. If it is, the x value is accepted.Otherwise, the x value is rejected and the algorithm tries again.Division of Computer Engineering 9
    • Randomized Algorithm Seminar Report ‘09 4. DETERMINISTIC ALGORITHM Goal is to solve the problem correctly (always) and quickly. Typicallythe number of steps should be polynomial in the size of the input. Input Algorithm Output 5 RANDOMIZED ALGORITHM A randomized algorithm is defined as an algorithm that is allowed toaccess a source of independent, unbiased random bits, and it is then allowed touse these random bits to influence its computation. Input Algorithm Output Random bits Formally, the algorithms performance will be a random variabledetermined by the random bits, with (hopefully) good expected value. The"worst case" is typically so unlikely to occur that it can be ignored. Bounds onthe performances of random algorithms depend on their random choices andnot on any assumptions about the inputs. It is important to distinguish thisform of probabilistic analysis of an algorithm, in which one assumes adistribution on the inputs and analyses an algorithm that may itself bedeterministic.Division of Computer Engineering 10
    • Randomized Algorithm Seminar Report ‘095.1 WHY RANDOMIZED ALGORITHMS? Simplicity: - This is the first and foremost reason for using randomizedalgorithms. There are numerous examples where an easy randomizedalgorithm can match (or even surpass) the performance of a deterministicalgorithm.Example: Sorting algorithms. The Merge-Sort algorithm is asymptotically best deterministicalgorithm. It is not too hard to describe. However, the same asymptoticrunning time can be achieved by the simple randomized Quick-sort algorithm.The algorithm picks a random element as a pivot and partitions the rest of theelements: those smaller than the pivot and those bigger than the pivot. Recurseon these two partitions. We will give the analysis of the running time later. Speed: - The best known randomized algorithms are faster than thebest known deterministic algorithms. This is achieved by requiring that thecorrect answer be found only with high probability or that the algorithmshould run in expected polynomial time. This means that the randomizedalgorithm may not find a correct answer in some cases or may take very longtime.Example: Checking if a multi-variate polynomial is the zero polynomial.There is no known deterministic polynomial-time algorithm that determines ifthe given multi-variate polynomial is the zero polynomial. On the other hand,there is a very simple and efficient randomized algorithm for this problem: justevaluate the given polynomial at random points. Note that such a polynomialcould be represented implicitly. e.g., as a determinant of a matrix whoseentries contain different variables.Division of Computer Engineering 11
    • Randomized Algorithm Seminar Report ‘09 6. LAS VEGAS AND MONTE CARLO There are two types of Randomized Algorithms:1) Las Vegas Algorithm2) Monte Carlo Algorithm6.1 LAS VEGAS ALGORITHM: - Las Vegas Algorithm: The randomized algorithm always produces thecorrect answer, but its runtime for each input is a random variable whoseexpectation is bounded.Example: Quick-sort algorithm6.2 MONTE CARLO ALGORITHM: - The randomized algorithm runs for a fixed number of steps for eachinput and produces an answer that is correct with a bounded probability. Thatis it may produce incorrect solution .It has a fixed deterministic running time.If the algorithm is run repeatedly with independent random choices each time,the failure probability can be made arbitrarily small, at the expense of runningtime. For decision problems (problems for which the answer to an instance isYES or NO), there are two kinds of Monte Carlo algorithms: those with one-sided error, and those with two-sided error. A Monte Carlo algorithm is saidto have two-sided error if there is a non-zero probability that it errs when itoutputs either YES or NO. It is said to have one-sided error if the probabilitythat it errs is zero for at least one of the possible outputs (YES / NO) that itproduces. Example: Min-Cut Algorithm. Which is better, Monte Carlo or LasVegas? The answer depends on the application. In some applications anincorrect solution may be catastrophic. A Las Vegas algorithm is by definitiona Monte Carlo algorithm with error probability zero. It is possible to derive aLas Vegas algorithm from a Monte Carlo algorithm. The efficiency of thederivation procedure depends on the time taken to verify the correctness of asolution to the problem.Division of Computer Engineering 12
    • Randomized Algorithm Seminar Report ‘09 We say that a Las Vegas algorithm is an efficient Las Vegas algorithmif on any input its expected running time is bounded by a polynomial functionof the input size. Similarly a Monte Carlo algorithm is an efficient MonteCarlo algorithm if on any input its worst-case running time is bounded by apolynomial function of the input size.Division of Computer Engineering 13
    • Randomized Algorithm Seminar Report ‘09 7. RANDOMIZED QUICKSORT7.1 TRADITIONAL QUICKSORT Consider sorting a set S of n numbers into ascending order. Pick the firstelement as the pivot element, say y. Partition the set S-{y} into two sets S1and S2 , where S1 consists of those elements of S that are smaller than y, andS2 has the remaining elements. Recursively sort S1 and S2 , then output theelements of S1 in ascending order , followed by y ,and then the elements of S2in ascending order. Analysis: - If we could find y in cn steps for some constant c, we could partition S-{y} in n-1 additional steps by comparing each element of S with y; thus thetotal number of steps in our sorting procedure would be given by therecurrence T (n) <= 2T(n/2) + (c+1) n,Where T(k) represents the time taken by this method to sort k numbers on theworst-case input. This recurrence has the solution T(n) <= c n log n for aconstant c. The difficulty with the above scheme in practice is finding theelement y that splits S-{y} into two sets of the same size. One simple solutionis to choose an element of S at random. This does not always ensure a splittergiving a roughly even split. However, it is reasonable to hope that in therecursive algorithm we will be lucky fairly often. The result is an algorithm wecall RandQS, for Randomized Quicksort.Division of Computer Engineering 14
    • Randomized Algorithm Seminar Report ‘097.2 RANDOMIZED QUICKSORT Randomized Quicksort algorithm makes random choices during execution. Algorithm RandQS: Input: A set of numbers S. Output: The elements of S sorted in increasing order. 1.Choose an element y uniformly at random from S: every element in S has equal probability of being chosen. 2.By comparing each element of S with y, determine the set S 1 of elements smaller than y and the set S 2 of elements larger than y. 3.Recursively sort S 1 and S 2 .Output the sorted version of S 1 , followed by y, and then the sorted version of S 2 .Analysis: - As for any sorting algorithms, we measure the running time of RandQSin terms of the number of comparisons it performs .Our goal is to analyze theexpected number of comparisons in an execution of RandQS. All thecomparisons are performed in Step 2. Let S(i) be the ith smallest element in the input list S. Define the random variable X ij to assume the value 1 if S(i) and S(j)are compared in an execution, and the value 0 otherwise. Thus X ij is a count ofcomparisons between S(i) and S(j), and so the total number of comparisons is ∑ ∑ ≥ ij =1 R E[ ∑ ∑ ≥ ij ]= ∑=1 ∑ ≥ [ ij ] Expected runtime t of RandQS is t= =1 R RDivision of Computer Engineering 15
    • Randomized Algorithm Seminar Report ‘09 Let P ij denote the probability that S(i) and S(j) are compared inan execution. Since X ij only assumes the values 0 and 1, E[X ij ] = P ij *1+ (1-P ij )*0 = P ijTo compute P ij , we make two observations. 1. There is a comparison between S(i) and S(j) if and only if S(i) or S(j) occurs earlier in the permutation ∏ than any element S(l) such that i<l<j. To see this, let S(k) be the earliest in ∏ from among all elements of rank between i and j. If k = i or j then S(i) will belong to the left sub-tree of S(k) while S(j) will belong to the right sub- tree of S(k), implying that there is no comparison between S(i) and S(j). Conversely, when k=I or j there is an ancestor-descendent relationship between S(i) and S(j), implying that the two elements are compared by RandQS. 2. Any of the elements S(i),S(I+1),…,S(j) is equally likely to be the first of these elements to be chosen as a partitioning element, and hence to appear first in ∏. Thus, the probability that this first element is either S(i) or S(j) is exactly 2/(j-i+1).Therefore, the expected runtimet = ∑ ∑ ≥ [ ij ] =1 = ∑ ∑ ≥ ij R =1 = ∑ ∑ ≥ 2 R =1 −+1 ≤ n ∑=1 2 ≅ 2n ln nNote that 1+ 1/2 + 1/3 + … +1/n ≅ln nRandomized Quicksort is a Las Vegas Algorithm.Division of Computer Engineering 16
    • Randomized Algorithm Seminar Report ‘09The expected running time holds for every input. It is an expectation thatdepends only on the random choices made by the algorithm, and not on anyassumptions about the distribution of the input. The behavior of a randomizedalgorithm can vary even on a single input, from one execution to another. Therunning time becomes a random variable, and the running time analysisinvolves understanding the distribution of this random variable.Division of Computer Engineering 17
    • Randomized Algorithm Seminar Report ‘09 8. RANDOMIZED MIN-CUT ALGORITHM Let G = (V,E) be a connected , undirected multigraph with n vertices.Amultigragh may contain multiple edges between any pair of vertices.A cut inG is a set of edges whose removal results in G being broken into two or morecomponents. A min-cut is a cut of minimum cardinality. For instance, say thisgraph represents a network, and we want to know how ”robust” it is in thesense of the the minimum number of links whose failure causes the network tobecome disconnected.The minimum cut problem is to find a cut of minimumsize. Min-cut algorithm Algorithm Min-Cut Input: Connected, undirected multigragh G(V,E). Output: Size of the min-cut. 1. while |V| >= 2 do 2. Pick an edge e randomly and contract it. 3. Remove Self Loops. 4. end while 5. Return |E| ; Once we have collapsed the first random edge, the rest of the algorithmproceeds recursively on the remaining (n − 1)-node graph. Here is a luckyexample.Division of Computer Engineering 18
    • Randomized Algorithm Seminar Report ‘09Division of Computer Engineering 19
    • Randomized Algorithm Seminar Report ‘09Analysis:- Look at what happens to the edges after they are contracted. Theybecome self loops and are removed. After the i-th iteration of the while loop,or the i-th contraction, how many nodes remain: n− i. Let us assume that nominimum-cut edge got contracted. (We want to know what is the probabilityof this ’lucky event’ happening) Each node in the contracted graph hasdegree>= k (Why? Because contractions do not decrease the min-cut). Thusafter the i-th iteration, the total number of edges in the graph is >= k(n−i)/2 .The probability q 1 of picking one of those k edges in the first mergingsteps ≤ k/(kn/2) ≤ n/2The probability p 1 of not picking any of those k edges in the first mergingstep ≥ (1-2/n)Repeat the same argument for the first n-2 merging steps.Probability p of not picking any of those k edges in all the merging steps ≥ (1-2/n)(1-2/(n-1))(1-2/(n-2))…(1-2/3) 2 2 2Therefore, the probability of finding the min-cut: −1 3 P ≥ (1- ) (1- )…………..(1- ) (−1)(−3)….(1) (−1)….3 = 2 (−1) = If we repeat the whole procedure n2/2 times, the probability of notfinding the min-cut is at most (1− 2/n2 )n 2 / 2 ≅ 1/ eDivision of Computer Engineering 20
    • Randomized Algorithm Seminar Report ‘09 By this process of repetition, we have managed to reduce theprobability of failure from 1-2/(n**2) to a more respectable 1/e. Furtherexecution of the algorithm will make the failure probability arbitrarily small-the only consideration being that repetitions increase the running time. Randomized Min-cut is a Monte Carlo Algorithm.Division of Computer Engineering 21
    • Randomized Algorithm Seminar Report ‘09 9. COMPLEXITY CLASSES A complexity class is a collection of languages all of whoserecognition problems can be solved under prescribed bounds on thecomputational resources. A language recognition problem is to decide whethera given string x ∑* belongs to L. An algorithm solves a language inrecognition problem for a specific language L by accepting (output YES) anyinput string contained in L , and rejecting (output NO) any input string notcontained in L.We are primarily interested in various forms of efficientalgorithms, where efficient is defined as being polynomial time. Recall that analgorithm has polynomial running time if it halts within nO(1) time on any inputof length n. Some basic complexity classes focusing on those involvingrandomized algorithms are 1) Randomized Polynomial time (RP) 2) Zero-error Probabilistic Polynomial time(ZPP) 3) Probabilistic Polynomial time(PP) 4) Bounded-error Probabilistic Polynomial time (BPP)9.1 CLASS RP The class RP (for randomized polynomial time) consists of alllanguages L that have a randomized algorithm A running in worst case x ∈ L ⇒ Pr[A(x) accepts] >= ½polynomial time such that for any input x in ∑*, x ∈ L ⇒ Pr[A(x) accepts] = 0 • •The choice of the bound on the error probability ½ is arbitrary. In fact , as wasobserved in the case of the min-cut algorithm, independent repetitions of thealgorithm can be used to go from the case where the probability of success ispolynomially small to the case where the probability of error is exponentiallyDivision of Computer Engineering 22
    • Randomized Algorithm Seminar Report ‘09small while changing only the degree of the polynomial that bounds therunning time.Thus,the success probability can be changed to an inversepolynomial function of the input size without significantly affecting thedefinition of RP. Observe that an RP algorithm is a Monte Carlo algorithm that can erronly when x L. this is referred to as one-sided error. The class co-RP consistsof languages that have polynomial time randomized algorithms erring only inthe case when x L.A problem belonging to both RP and co-RP can be solvedby a randomized algorithm with zero-sided error, ie a Las Vegas algorithm.9.2 CLASS ZPP The class ZPP is the class of languages which have Las Vegasalgorithms running in expected polynomial time. ZPP = RP ∩ co-RP9.3 CLASS PP The class PP (for probabilistic polynomial time ) consists of alllanguages L that have a Randomized algorithm A running in worst casepolynomial time such that for any input x in ∑*, x ∈ L ⇒ Pr[A(x) accepts] > ½ x ∈ L ⇒ Pr[A(x) accepts] < ½ • • To reduce the error probability of a two-sided error algorithm, we canperform several independent iterations on the same input and produce theoutput that occurs in the majority of these iterations. Unfortunately, thedefinition of the class PP is rather weak: because we have no bound on howfar from ½ the probabilities are, it may not be possible to use a small numberof repetitions of an algorithm A with such two-sided error probability to obtainan algorithm with significantly small error probability.Division of Computer Engineering 23
    • Randomized Algorithm Seminar Report ‘099.4 CLASS BPP The class BPP (for bounded error probabilistic polynomial time)consists of all languages L that have a randomized algorithm A running in x ∈ L ⇒ Pr[A(x) accepts] >= ¾.worst case polynomial time such that for any input x in ∑*, x ∈ L ⇒ Pr[A(x) accepts] <= ¼. • • For this class of algorithms the error probability can be reduced to 1/2nwith only a polynomial number of iterations. In fact the probability bounds ¾and ¼ can be changed to ½ + 1/p(n) and ½ -1/p(n), respectively, for anypolynomially bounded function p(n) without affecting this error reductionproperty or the definition of the class BPP to a significant extent.Division of Computer Engineering 24
    • Randomized Algorithm Seminar Report ‘09 10. ADVANTAGES There are two principal advantages to randomized algorithms. The firstis performance. For many problems, randomized algorithms run faster thanbest-known deterministic algorithms. Second, many randomized algorithms are simpler to describe andimplement than deterministic algorithms of comparable performance.Randomized Quicksort is an example.Division of Computer Engineering 25
    • Randomized Algorithm Seminar Report ‘09 11. DISADVANTAGES Difficulty to sample the distributions using only random bits:-Forexample, consider an algorithm that picks a random real number from someinterval. This requires infinitely many random bits. There is sometimes a non-trivial computational overhead associatedwith sampling from a seemingly well-behaved distribution. For example,consider the program of using a source of unbiased random bits to sampleuniformly from a set S whose cardinality is not a power of 2.Division of Computer Engineering 26
    • Randomized Algorithm Seminar Report ‘09 12. SCOPE  Number theoretic algorithms: Primary testing (Monte Carlo)  Data structures: Sorting, order statistics, searching, and computational geometry.  Algebraic identities: Polynomial and matrix identity verification and Interactive proof systems. Mathematical programming: Faster algorithms for linear Programming, Rounding linear program solutions to integer program solutions,  Graph algorithms: Minimum spanning trees, shortest paths and minimum cuts.  Counting and enumeration: Matrix permanent and Counting combinatorial structures. Parallel and distributed computing: Deadlock avoidance, distributed Consensus.  Probabilistic existence proofs: Show that a combinatorial object arises with nonzero probability among objects drawn from a suitable probability space.Division of Computer Engineering 27
    • Randomized Algorithm Seminar Report ‘09 13. CONCLUSION The ideas underlying randomized algorithms can be traced back toMonte Carlo methods used in numerical analysis, statistical physics, andsimulation. A randomized algorithm is defined as an algorithm that typicallyuses the random bits as an auxiliary input to guide its behavior. It achievesgood performance in the "average case". Formally, the algorithmsperformance will be a random variable determined by the random bits, with(hopefully) good expected value. The "worst case" is typically so unlikely tooccur that it can be ignored. Randomized algorithms take a random bit torandomize the algorithm. For randomized quick sort expected running timeholds for every input. There are some interesting complexity classes involving randomized algorithms: 1. Randomized Polynomial time (RP) 2. Zero-error Probabilistic Polynomial time (ZPP) 3. Probabilistic Polynomial time (PP) 4. Bounded-error Probabilistic Polynomial time (BPP).Division of Computer Engineering 28
    • Randomized Algorithm Seminar Report ‘09 14. BIBLIOGRAPHYBooks:-Rajeev Motwani and Prabhakar Raghavan: Randomized Algorithms, Cambridge University Press 1995.Thomas H Cormen, Charles E Leiserson,Ronald L Rivest and Clifford Stein: Introduction to Algorithms,Websites:-http://en.wikipedia.org/wiki/Probabilistic_algorithmhttp://en.wikipedia.org/wiki/Las_Vegas_algorithmhttp://www.nist.gov/dads/HTML/LasVegas.htmlhttp://www.nist.gov/dads/HTML/monteCarlo.htmlDivision of Computer Engineering 29
    • Randomized Algorithm Seminar Report ‘09Division of Computer Engineering 30