Concept

Randomized algorithm

Summary
A randomized algorithm is an algorithm that employs a degree of randomness as part of its logic or procedure. The algorithm typically uses uniformly random bits as an auxiliary input to guide its behavior, in the hope of achieving good performance in the "average case" over all possible choices of random determined by the random bits; thus either the running time, or the output (or both) are random variables. One has to distinguish between algorithms that use the random input so that they always terminate with the correct answer, but where the expected running time is finite (Las Vegas algorithms, for example Quicksort), and algorithms which have a chance of producing an incorrect result (Monte Carlo algorithms, for example the Monte Carlo algorithm for the MFAS problem) or fail to produce a result either by signaling a failure or failing to terminate. In some cases, probabilistic algorithms are the only practical means of solving a problem. In common practice, randomized algorithms are approximated using a pseudorandom number generator in place of a true source of random bits; such an implementation may deviate from the expected theoretical behavior and mathematical guarantees which may depend on the existence of an ideal true random number generator. As a motivating example, consider the problem of finding an ‘a’ in an array of n elements. Input: An array of n≥2 elements, in which half are ‘a’s and the other half are ‘b’s. Output: Find an ‘a’ in the array. We give two versions of the algorithm, one Las Vegas algorithm and one Monte Carlo algorithm. Las Vegas algorithm: findingA_LV(array A, n) begin repeat Randomly select one element out of n elements. until 'a' is found end This algorithm succeeds with probability 1. The number of iterations varies and can be arbitrarily large, but the expected number of iterations is Since it is constant, the expected run time over many calls is . (See Big Theta notation) Monte Carlo algorithm: findingA_MC(array A, n, k) begin i := 0 repeat Randomly select one element out of n elements.
About this result
This page is automatically generated and may contain information that is not correct, complete, up-to-date, or relevant to your search query. The same applies to every other page on this website. Please make sure to verify the information with EPFL's official sources.