Las Vegas Algorithm
Updated 2026-07-28
Summary
In computing, a Las Vegas algorithm is a randomized algorithm that always gives the correct solution; that is, it always returns the correct result, or returns failure. In other words, a Las Vegas algorithm does not gamble with the correctness of the result, but rather with the resources used for computation. A simple example is randomized quicksort, where the pivot is chosen randomly, but the sorting result is always consistent. The counterpart to the Las Vegas algorithm is the Monte Carlo algorithm.
Definition
In computing, a Las Vegas algorithm is a randomized algorithm that always gives the correct solution; that is, it always returns the correct result, or returns failure. In other words, a Las Vegas algorithm does not gamble with the correctness of the result, but rather with the resources used for computation. A simple example is randomized quicksort, where the pivot is chosen randomly, but the sorting result is always consistent. The counterpart to the Las Vegas algorithm is the Monte Carlo algorithm, which may return an incorrect result with a certain probability, but its running time is deterministic or has an upper bound.
Introduction
How to use
In computing, a Las Vegas algorithm is a randomized algorithm that always gives the correct solution; that is, it always returns the correct result, or returns failure. In other words, a Las Vegas algorithm does not gamble with the correctness of the result, but rather with the resources used for computation. A simple example is randomized quicksort, where the pivot is chosen randomly, but the sorting result is always consistent. The counterpart to the Las Vegas algorithm is the Monte Carlo algorithm.
Mechanism
A Las Vegas algorithm is a randomized algorithm whose running time is random but whose result is always correct, and if necessary, it relies on random retries to ensure correctness. It is contrasted with the Monte Carlo algorithm (which may produce incorrect results but has fixed time).
Practice
In progress 0/1Practice this model in one real situation:
Cases
- Randomized quicksort's random pivot selection is of the LV style (the result is always correct). Some integer factorization methods use random trials to ensure correctness.
Common pitfalls
- Confusing it with Monte Carlo, mistakenly thinking the result may be wrong. Ignoring the retry limit can cause the worst case to get out of control.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E6%8B%89%E6%96%AF%E7%BB%B4%E5%8A%A0%E6%96%AF%E7%AE%97%E6%B3%95verified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS