- Las Vegas algorithm
In
computing , a Las Vegas algorithm is arandomized algorithm that never gives incorrect results; that is, it always produces the correct result or it informs about the failure. In other words, a Las Vegas algorithm does not gamble with the verity of the result --- it only gambles with the resources used for the computation. A simple example is randomizedquicksort , where the pivot is chosen randomly, but the result is always sorted. The usual definition of a Las Vegas algorithm includes the restriction that the "expected" run time always be finite, when the expectation is carried out over the space of random information, or entropy, used in the algorithm.The
complexity class ofdecision problem s that have Las Vegas algorithms with expected polynomial runtime isZPP .It turns out that
:
which is intimately connected with the way Las Vegas algorithms are sometimes constructed. Namely the class RP consists of all decision problems for which a randomized polynomial-time algorithm exists that always answers correctly when the correct answer is "no", but is allowed to be wrong with a certain probability bounded away from one when the answer is "yes". When such an algorithm exists for both a problem and its complement (with the answers "yes" and "no" swapped), the two algorithms can be run simultaneously and repeatedly: a few steps of each, taking turns, until one of them returns a definitive answer. This is the standard way to construct a Las Vegas algorithm that runs in expected polynomial time. Note that in general there is no worst case upper bound on the run time of a Las Vegas algorithm.
Las Vegas algorithms can be contrasted with Monte Carlo algorithms, in which the resources used are bounded but the answer is not guaranteed to be correct 100% of the time.
See also
*
Randomness
*Monte Carlo method External links
* [http://www.datastructures.info/the-las-vegas-algorithmmethod/ Example code of Miller-Rabin primality test using the Las Vegas method, C++]
References
*Algorithms and Theory of Computation Handbook, CRC Press LLC, 1999, "Las Vegas algorithm", in Dictionary of Algorithms and Data Structures [online] , Paul E. Black, ed., U.S. National Institute of Standards and Technology. 17 July 2006. (accessed TODAY) Available from: [http://www.nist.gov/dads/HTML/lasVegas.html]
Wikimedia Foundation. 2010.