Skip to content

Randomized Algorithm

A randomized algorithm makes internal random choices and states its output or cost guarantee over those choices for each fixed input.

Version
v1 · 2026-10-03 · History
Domain-specific #
13555
Domain group
Applied Sciences & Engineering
Origin domain
Computer Science & Software Engineering
Subdomain
Algorithm Design → Computer Science & Software Engineering
Aliases
Probabilistic Algorithm, Randomised Algorithm

Core Idea

A randomized algorithm makes internal random choices that affect its execution. Its expected-cost or success guarantee is taken over these choices for each fixed input, not merely over a random collection of inputs. Random-pivot quicksort is always correct but has random cost; one run of random min-cut contraction has a bounded chance of finding an optimum.[1][2]

How would you explain it like I'm…

Coin-Flipping Recipe

Some computer recipes flip coins while they work, to decide what to try next. For the very same puzzle, different coin flips might take a different path or a different amount of time. A randomized algorithm is a recipe like that, built so the coin flips help it do well on any puzzle.

Algorithms That Flip Coins

A randomized algorithm is a set of computer instructions that makes some of its own random choices, like flipping coins, while it works. Even on the very same problem, it might run a bit differently each time. Some kinds always give the right answer but take a random amount of time. Other kinds always finish quickly but have a small, controlled chance of a wrong answer, which you can shrink by running them again. The promises are about the coin flips, and they hold for every problem you give it.

Algorithms with Internal Randomness

A randomized algorithm takes a normal input plus a stream of random choices it generates itself. For the same input, different random choices can change the steps, the running time, or even the answer. Its guarantees are about the random choices for each input, such as an expected running time or a small chance of error, which is different from measuring a normal program on randomly chosen inputs. There are two main types. Las Vegas algorithms, like quicksort with a random pivot, are always correct but take a random amount of time. Monte Carlo algorithms, like Karger's contraction method for finding a minimum cut, have bounded running time but may be wrong with some bounded probability, which repeated runs can reduce. Neither type is automatically faster than a non-random algorithm.

 

A randomized algorithm receives a problem input together with an internally supplied sequence of random choices; for a fixed input, varying those choices can change the execution path, running time, or output. Its guarantees are stated over the random choices for each input: expected running time, high-probability bounds, or a controlled error probability. This is distinct from average-case analysis of a deterministic algorithm over a random input distribution; for instance, randomized quicksort's expected time bound holds for every input array. The two standard contracts are alternatives. Las Vegas algorithms never return an incorrect answer but have random running time, as with random-pivot quicksort. Monte Carlo algorithms bound their work but accept a bounded failure probability, as with a single run of Karger's contraction, which may return a non-minimum cut; independent repetitions raise the probability that the smallest cut found is minimum. Neither label implies superiority over deterministic competitors.

Scope of Application

In quicksort, pivot choices change recursion shape while expected running time remains \(O(n\log n)\) on every input array. In graph min-cut, avoiding edges of a fixed minimum cut during random contractions preserves that cut, and repeated independent runs raise the chance of finding an optimum.[1][3]

Clarity

Ask what is fixed, what is sampled and what is guaranteed. Deterministic code measured on random inputs is not thereby a randomized algorithm. A fixed pseudorandom seed yields a deterministic run unless a seed distribution or computational model is declared.

Manages Complexity

Probability bounds summarize many possible traces without promising that each trace is fast or successful. Las Vegas and Monte Carlo describe alternative correctness/time contracts, not two mandatory features of every algorithm.

Abstract Reasoning

On [1,2,3,4], pivot 2 gives balanced-enough subproblems, while repeated extreme pivots give a long chain; both sort correctly. In a four-vertex multigraph with two parallel edges within each pair and a single bridge between pairs, preserving the unique minimum cut requires avoiding the bridge through both contractions, with probability (4/5)×(2/3)=8/15. These tiny traces reveal the mechanism but do not replace general proofs.[1][3]

Knowledge Transfer

Sorting and min-cut share fixed input, internal sampling, choice-dependent execution and a per-input probability contract. Their actual bounds and failure conditions require separate proofs. The live Algorithm prime is the strict genus; internal random choice specializes a finite executable procedure.

Relationships to Other Abstractions

Local relationship map for Randomized AlgorithmParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Randomized AlgorithmDOMAINPrime abstraction: Algorithm — is a kind ofAlgorithmPRIME

Current abstraction Randomized Algorithm Domain-specific

Parents (1) — outgoing typed relations

  • Randomized Algorithm is a kind of Algorithm Prime

    A randomized algorithm is an algorithm whose internal random choices affect fixed-input behavior.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Randomized Algorithm sits in a sparse region of the domain-specific corpus (74th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.

Family — Storage & Lookup Data Structures (22 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14

References

[1] MIT 6.046J, Randomized Algorithms lecture. registry ↩a ↩b ↩c

[2] Karger, MIT 6.856J, Lecture 1. registry ↩

[3] MIT 6.856J, contraction-probability solution. registry ↩a ↩b