The interview problem

Practice prompt

Compare two rankings using Kendall correlation and explain what changes when there are ties.

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

Assume the same items appear once in both complete rankings. Enumerate item pairs: concordant pairs retain relative order and discordant pairs reverse it. Without ties, tau is their count difference divided by total pairs. With ties, choose a documented tie-adjusted statistic such as tau-b rather than pretending tied pairs are ordered. For incomplete top-k lists, first define the treatment of missing items.

2. Trace the design or derivation

Define shared items
  → classify pairs
  → adjust ties
  → summarize agreement

One adjacent swap changes one pair, while moving the bottom item to the top reverses its relation with every other item. This makes the pair interpretation useful when explaining errors to reviewers. If only the first recommendation matters, supplement the global pair score with a top-position metric.

3. Calculate the example

For orders A,B,C,D and A,C,B,D, only pair B,C reverses. Five pairs agree and one disagrees, so tau=(5−1)/6=2/3. Swapping nearby items can have a modest pairwise penalty even if the top position has special product importance.

4. Failure cases and trade-offs

Equal weighting of all pairs may not match user value at the top of a list. Ties and truncated lists can change denominators substantially. A top-weighted task metric may be more appropriate, but is a different estimand. Report the chosen convention alongside the number.

5. Validation, follow-ups and self-review

Enumerate all six pairs by hand and test a reversed list. Follow-up: how would you compare lists containing different items? Self-review: define the item universe and tie policy before computing agreement.

Sources and related practice

Technical reference: docs.scipy.org — Concordant pairs and tie-adjusted correlation.

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 Interpret ROC AUC through positive-negative pairs; Measure monotonic association with ranks.

Continue your preparation

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