Skip to content

Nearest Pair Hot Sheet

Use this page when the task is:

one static set of planar points -> one global closest Euclidean pair

and you want the shortest route back to the active strip invariant.

Do Not Use When

  • the points change online
  • the task is really event ordering over segments or rectangles
  • the statement wants the outer boundary of the points
  • the metric or dimension changed enough that the usual 2D packing argument no longer applies directly

Choose By Signal

Core Invariants

  • points are processed in increasing x
  • the active set contains exactly the points still close enough in x to matter
  • the active set is ordered by y, because the surviving candidate window is a y interval
  • internal comparisons are safest in squared distance, even if the final answer needs one square root

Main Traps

  • mixing squared and unsquared distance in the strip test
  • forgetting duplicate points imply answer 0
  • ordering the active set by the wrong coordinate
  • treating this as a hull or generic geometry-predicate problem

Exact Starters In This Repo

Reopen Paths