Why it matters
KD-trees enable spatial + nearest-neighbor search. Understanding shapes ML + graphics + GIS work.
Advertisement
The architecture
Node: point + axis for split.
Left subtree: points less along axis; right: greater.
Rotate axis per level.
Advertisement
How it works end to end
Nearest neighbor: walk down; unwind checking if other side could have closer point.
Range query: report points in axis-aligned box.
Curse of dimensionality: efficiency degrades above ~20 dimensions.
Alternatives: ball tree, R-tree, LSH for high dimensions.