Randomized Algorithms

Research Depth 66 in the knowledge graph I know this Set as goal
Unlocks 20 downstream topics
randomized-algorithms probabilistic-analysis expected-time algorithm-design

Core Idea

A randomized algorithm uses random coin flips as part of its logic, making its behavior (runtime, output, or both) a random variable rather than a deterministic quantity. Randomization often yields simpler, faster, or more elegant algorithms than the best known deterministic alternatives. Randomized quicksort achieves O(n log n) expected time with no adversarial worst case; randomized min-cut (Karger's algorithm) finds minimum cuts with high probability through simple edge contractions. The analysis of randomized algorithms relies on probability tools — linearity of expectation, tail bounds, and the probabilistic method — to provide rigorous guarantees despite the inherent unpredictability.

Explainer

You already understand deterministic algorithm analysis — given an input, the algorithm follows a fixed sequence of steps and you analyze the worst case. Randomized algorithms break this model by introducing coin flips into the algorithm's logic. The algorithm's behavior on a fixed input becomes a random variable, and the analysis shifts from worst-case determinism to probabilistic guarantees. This is not the same as average-case analysis over random inputs: the randomness is internal to the algorithm, and the guarantees hold for every input.

The power of randomization is surprising. Randomized quicksort achieves O(n log n) expected time on every input — no adversary can force quadratic behavior because the adversary cannot predict the random pivot choices. The analysis uses linearity of expectation: define indicator random variables X_ij for whether elements i and j are compared, compute Pr[X_ij = 1] = 2/(j-i+1) from the observation that i and j are compared exactly when one of them is the first pivot chosen from the range between them, then sum over all pairs to get the harmonic series. No independence assumptions are needed because linearity of expectation holds unconditionally.

Karger's min-cut algorithm illustrates a different flavor of randomization. The algorithm repeatedly contracts a uniformly random edge until only two vertices remain, and the edges between them form a candidate cut. A single run finds a specific minimum cut with probability at least 2/n(n-1), which seems terrible — but repeating O(n^2 log n) times and keeping the best cut drives the failure probability to inverse polynomial. This technique of probability amplification through independent repetition is a recurring theme: weak probabilistic guarantees become strong ones through repetition, as long as verification is cheap.

The theoretical foundation for analyzing randomized algorithms draws on tools you know from probability — linearity of expectation, Markov's and Chebyshev's inequalities, Chernoff bounds — and applies them in algorithmic contexts. Tail bounds are particularly important: they tell you not just the expected behavior but how tightly concentrated the actual behavior is around the expectation. An algorithm with O(n log n) expected time is less useful if the variance is huge, but Chernoff bounds often show that the running time is sharply concentrated, deviating from the expectation with only exponentially small probability. This combination of simplicity, efficiency, and provable concentration makes randomized algorithms indispensable in modern algorithm design.

Practice Questions 4 questions

Prerequisite Chain

Counting to 10Counting to 20Understanding ZeroThe Number ZeroCounting to FiveOne-to-One CorrespondenceCombining Small Groups Within 5Addition Within 10Addition Within 20Two-Digit Addition Without RegroupingTwo-Digit Addition with RegroupingAddition Within 100Repeated Addition as MultiplicationMultiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Two-Digit by One-Digit DivisionDivision with RemaindersRemainders and Quotients in DivisionDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueReading and Writing DecimalsComparing and Ordering DecimalsAdding and Subtracting DecimalsMultiplying DecimalsDividing DecimalsDividing FractionsMixed Number ArithmeticOrder of OperationsInteger Order of OperationsVariable ExpressionsCombining Like TermsOne-Step EquationsTwo-Step EquationsSolving Multi-Step EquationsEquations with Variables on Both SidesLiteral EquationsSlope-Intercept FormPoint-Slope FormWriting Linear EquationsParallel and Perpendicular Line SlopesGraphing Linear EquationsPiecewise FunctionsStep FunctionsComposition of FunctionsInverse FunctionsRadical Functions and GraphsRational ExponentsExponential Functions and GraphsLogarithms IntroductionTime and Space ComplexityTime Complexity Classes: P and EXPTIMENondeterministic Time Complexity and NPThe P vs. NP ProblemComplexity Class P: Polynomial TimeRandomized Algorithms

Longest path: 67 steps · 401 total prerequisite topics

Prerequisites (4)

Leads To (17)