Skip to content
Data Structures and Algorithms / Analysis Foundations and the Design Loop

Probabilistic Analysis and Randomized Algorithms

Some algorithms have a running time that genuinely depends on chance — either because the input itself is drawn from some distribution (the order in which trades arrive), or because the algorithm itself flips coins (randomizing quicksort's pivot choice, or a Monte Carlo estimator). Neither case is well described by "worst case" or "best case" alone, and both are handled by the same technique: write the quantity you want to bound as a sum of simple 0/10/1 indicator random variables, then take the expectation of the sum using linearity of expectation — a property that needs no independence assumption whatsoever. This note develops that technique on the hiring problem, a small combinatorial example CLRS uses precisely because its answer (O(ln⁡n)O(\ln n) expected interviews) is both surprising and a two-line proof once the indicator-variable machinery is in place, then explains why randomized algorithms — algorithms that make random choices as part of their own logic, independent of the input's distribution — give you a probabilistic guarantee that holds regardless of what the adversary hands you.
Learning objectives. By the end of this note you should be able to:
  • distinguish probabilistic analysis (about a distribution over inputs) from a randomized algorithm (about the algorithm's own coin flips);
  • define an indicator random variable for an event and compute its expectation directly from the definition;
  • apply linearity of expectation to compute the expected value of a sum of (possibly dependent) indicator variables;
  • explain, at an intuitive level, why randomizing an algorithm's choices can convert an exploitable worst case into a robust expected-case guarantee.

In this lesson

  1. Probabilistic analysis: the hiring problem
  2. Randomized algorithms

Before you start

The full lesson, with worked examples and exercise solutions, is for members.

Read the full lesson

New to SelfMadeQuant.com? See membership options or explore the curriculum.