Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M4306

Las Vegas Algorithm

Las Vegas Algorithm
DecideHigh supportDecision Science
Included
account_tree

Updated 2026-07-28

Loading revision record…

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.

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/1

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%

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.

  • link
    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%95ZH · Explicit
    verified
account_treeGenealogyexpand_more

RELATED MODELS