The interview problem

Practice prompt

Estimate the risk of at least one collision when assigning random identifiers from a finite space.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

For n independent uniform draws from N values, no-collision probability is the product of (1−i/N) for i=0,…,n−1. When collisions are sparse, approximate collision probability by 1−exp(−n(n−1)/(2N)).

2. Trace the design or derivation

Identifier space
  → pair count
  → no-collision product
  → approximation

A uniqueness constraint with retry can convert a collision into extra work, but it still needs a bounded retry policy and trustworthy randomness. Distinguish accidental collision resistance from resistance to deliberate guessing; those are separate security requirements.

3. Calculate the example

With n=1,000 and N=1,000,000, the exponent is −0.4995 and collision probability is about 39.3%. A million possible values is not enough to make a thousand draws nearly collision-free.

4. Failure cases and trade-offs

Nonuniform generators and shared seeds make the model optimistic. Expected colliding pairs and probability of any collision are different quantities.

5. Validation, follow-ups and self-review

Compute the exact product for small examples. Follow-up: how many bits meet a specified lifetime risk? Self-review: count pairs and state generator assumptions.

Sources and related practice

Technical reference: pi.math.cornell.edu — No-collision product under uniform independent draws.

Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Allocate sortable identifiers across regions; Count distinct identifiers across overlapping partitions.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.