Expected Number of Loops When Each Server Forwards to a Random Peer

Last updated: November 29, 2026

Quick Overview

Ten servers are arranged by a random permutation so each forwards to exactly one server (possibly itself) and receives from exactly one. What is the expected number of forwarding loops, and the probability that all ten servers form one single loop?

Meta
Statistics & Math
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Statistics & Math
Hard

0

0

0 solved


Ten servers are arranged by a random permutation so each forwards to exactly one server (possibly itself) and receives from exactly one. What is the expected number of forwarding loops, and the probability that all ten servers form one single loop?

Infrastructure interviews at Meta sometimes include probability about random structures like hash rings and forwarding tables. This question tests cycle structure of random permutations, linearity of expectation over a clever indicator, and verification by simulation.

What the Interviewer Expects
  • Identifies loops as permutation cycles
  • Derives E[cycles] = H_n using per-element or per-length indicators
  • Computes H_10 of about 2.93
  • Shows P(single cycle) = (n-1)!/n! = 1/n
  • Checks with a simulation or small exact case
Key Topics to Cover
Random permutations
Cycle structure
Harmonic numbers
Linearity of expectation
Simulation check
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 probability two specific servers are in the same loop?
  • What is the expected length of the loop containing server 1?
  • How does the expected number of self-loops compare?
  • How would you generate a uniformly random single-cycle permutation?
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 uniformly random permutation σ\sigma of 10 servers; server ii forwards to σ(i)\sigma(i). A loop is a cycle of σ\sigma, including fixed points (a server forwarding to itself)....

Approach

Expected cycles: each cycle can be credited as 1/∣cycle∣1/|\text{cycle}| to each of its members, so #cycles=∑i1/Li\#\text{cycles}=\sum_i 1/L_i where LiL_i is the length of ii's cycle. Known fact (and derivable by build...


Submit Your Answer
Markdown supported