🧮 Brain Teaser

Expected Number of Records


You observe a sequence that is a uniformly random permutation of 1,2,,n1, 2, \ldots, n.

Element σ(k)\sigma(k) is called a record (or left-to-right maximum) if σ(k)>σ(j)\sigma(k) > \sigma(j) for all j<kj < k.

What is the expected number of records?

ExpectationLinearity of expectationPermutationsHarmonic numbers

Answer: Expected Number of Records

Key Idea: Linearity of expectation + symmetry Difficulty: 2/5


Step-by-Step Solution

Step 1: Reframe using indicator variables

Instead of thinking about the total count directly, define:

Xk={1if position k is a record0otherwiseX_k = \begin{cases} 1 & \text{if position } k \text{ is a record} \\ 0 & \text{otherwise} \end{cases}

Then the total number of records is:

X=X1+X2++XnX = X_1 + X_2 + \cdots + X_n

By linearity of expectation:

E[X]=E[X1]+E[X2]++E[Xn]=k=1nP(position k is a record)E[X] = E[X_1] + E[X_2] + \cdots + E[X_n] = \sum_{k=1}^n P(\text{position } k \text{ is a record})

This is the trick — we reduced the problem to computing one simple probability at each position.


Step 2: Compute the probability at position k

Position kk is a record if σ(k)\sigma(k) is larger than everything before it — i.e., σ(k)\sigma(k) is the maximum of {σ(1),σ(2),,σ(k)}\{\sigma(1), \sigma(2), \ldots, \sigma(k)\}.

Key symmetry argument: Among the first kk elements, all k!k! orderings are equally likely. So each of the kk elements is equally likely to be the largest.

Therefore:

P(position k is a record)=1kP(\text{position } k \text{ is a record}) = \frac{1}{k}

  • Position 1 is always a record (trivially the max of itself): P=1P = 1
  • Position 2 is a record if σ(2)>σ(1)\sigma(2) > \sigma(1): P=1/2P = 1/2
  • Position 3 is a record if σ(3)\sigma(3) is the max of the first 3: P=1/3P = 1/3
  • ... and so on.

Step 3: Sum up

E[X]=k=1n1k=1+12+13++1n=HnE[X] = \sum_{k=1}^n \frac{1}{k} = 1 + \frac{1}{2} + \frac{1}{3} + \cdots + \frac{1}{n} = H_n

This is the harmonic number HnH_n.


What does this mean concretely?

For n=52n = 52 (a deck of cards), the expected number of records is H524.5H_{52} \approx 4.5.

As nn grows large, HnlnnH_n \approx \ln n, so even in a permutation of a million elements, you only expect about ln(1,000,000)14\ln(1{,}000{,}000) \approx 14 records.


Why linearity of expectation is so powerful here

The events "X1=1X_1 = 1", "X2=1X_2 = 1", etc. are not independent — whether position 3 is a record depends on positions 1 and 2. Normally this would make computing E[X]E[X] complicated.

But linearity of expectation holds regardless of independence. You never need to worry about how the XkX_k's interact — just compute each E[Xk]E[X_k] on its own.

Type: ProbabilityEdit on GitHub ↗