When would you choose Manhattan distance over Euclidean distance in KNN?

Quick Overview

Asks when Manhattan distance is a better choice than Euclidean distance for k-nearest neighbors. Tests understanding of how each metric weighs per-feature differences, how they behave with outliers, sparse data and many dimensions, and how to choose between them in practice.

When would you choose Manhattan distance over Euclidean distance in KNN?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

K-nearest neighbors depends entirely on the distance function used to find neighbors. When would you choose Manhattan distance over Euclidean distance in KNN? ```hint One large difference Compare how each distance responds when a candidate matches the query on every feature except one, where it is far off. ``` ```hint Many features Consider how the gap between the nearest and farthest points changes as the number of features grows, and whether the metric affects that. ``` ### What a Strong Answer Covers - How each distance combines per-feature differences, with the formulas. - How each one responds to a large difference in a single feature and to noisy features. - How the choice behaves in high-dimensional and sparse data. - The kinds of feature spaces where each metric fits, and how to choose in practice. ### Follow-up Questions - Why does feature scaling matter for both distances, and how would you scale features that have outliers? - Manhattan distance depends on the orientation of the coordinate axes and Euclidean distance does not. When does that matter? - What happens if you use a Minkowski distance with $p$ below 1? - Which distance would you use for TF-IDF text vectors, and why might neither of these two be the best choice?

Overview: Asks when Manhattan distance is a better choice than Euclidean distance for k-nearest neighbors. Tests understanding of how each metric weighs per-feature differences, how they behave with outliers, sparse data and many dimensions, and how to choose between them in practice.

General logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

K-nearest neighbors depends entirely on the distance function used to find neighbors. When would you choose Manhattan distance over Euclidean distance in KNN?

What a Strong Answer Covers Guidance

  • How each distance combines per-feature differences, with the formulas.
  • How each one responds to a large difference in a single feature and to noisy features.
  • How the choice behaves in high-dimensional and sparse data.
  • The kinds of feature spaces where each metric fits, and how to choose in practice.

Follow-up Questions Guidance

  • Why does feature scaling matter for both distances, and how would you scale features that have outliers?
  • Manhattan distance depends on the orientation of the coordinate axes and Euclidean distance does not. When does that matter?
  • What happens if you use a Minkowski distance with pp below 1?
  • Which distance would you use for TF-IDF text vectors, and why might neither of these two be the best choice?