Expected Number of Review Loops in a Random Code Review Rotation

Last updated: November 29, 2026

Quick Overview

Twenty engineers are each assigned one other person's change to review by a uniformly random permutation (self-review allowed for this analysis). Find the expected number of closed review loops and the probability that everyone forms a single loop.

Google
Statistics & Math
Quantitative Researcher
Google
November 29, 2026
Quantitative Researcher
Onsite
Statistics & Math
Hard

0

0

0 solved


Twenty engineers are each assigned one other person's change to review by a uniformly random permutation (self-review allowed for this analysis). Find the expected number of closed review loops and the probability that everyone forms a single loop.

Permutation structure questions appear in Google quantitative and research interviews because they reward clever use of linearity of expectation. The interviewer checks that you can count cycles containing a given element and turn that into harmonic numbers.

What the Interviewer Expects
  • Model the assignment as a random permutation and loops as cycles
  • Show the length of the cycle containing a given person is uniform
  • Derive the expected number of cycles as the harmonic number
  • Compute the probability of a single n-cycle
  • Verify by simulation
Key Topics to Cover
random permutations
cycle decomposition
linearity of expectation
harmonic numbers
simulation
How to Approach This
  1. Define your hypotheses (H0 and H1) clearly before performing any test.
  2. Calculate required sample size BEFORE running an experiment, using power analysis.
  3. Remember the Central Limit Theorem: sample means become approximately normal with large n.
  4. Watch for Simpson's paradox. Always segment data by key dimensions.
  5. Distinguish between statistical significance and practical significance.
Possible Follow-up Questions
  • What is the expected number of loops of length exactly k?
  • How would you sample a uniformly random single-loop assignment?
  • What is the variance of the number of cycles?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Browse Statistics Questions
Sample Answer
Clarify

A uniform permutation σ\sigma of {1,…,n}\{1, \dots, n\} maps each engineer to the person whose change they review. Following reviewer links from anyone eventually returns to them, so the permutation split...

Approach

Key fact: the cycle containing person 1 has length uniform on {1,…,n}\{1, \dots, n\}. Build it step by step: from person 1, σ(1)\sigma(1) returns to 1 with probability 1/n1/n; otherwise, the next step returns...


Submit Your Answer
Markdown supported