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.
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
How to Approach This
- Define your hypotheses (H0 and H1) clearly before performing any test.
- Calculate required sample size BEFORE running an experiment, using power analysis.
- Remember the Central Limit Theorem: sample means become approximately normal with large n.
- Watch for Simpson's paradox. Always segment data by key dimensions.
- 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 QuestionsSample Answer
Clarify
A uniform permutation of 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 . Build it step by step: from person 1, returns to 1 with probability ; otherwise, the next step returns...