Overview
A k-d Tree alternates or chooses split dimensions to organize points for nearest-neighbor and range queries.
Indexes points by recursively splitting space along coordinate axes.
Compact metadata for implementation and discovery.
A k-d Tree alternates or chooses split dimensions to organize points for nearest-neighbor and range queries.
Quick facts
Runtime and memory behavior at a glance.
Best
O(log n)
Average
O(log n) average query
Worst
O(n)
Space
O(n)
skip far branch if distance_to_split_plane >= best_distanceAvoids searching a branch that cannot contain a closer point.
Show points split by alternating vertical and horizontal lines.
k-d Trees work best in low or moderate dimensions.
What each reference supports for this entry.
Original k-d tree reference for multidimensional associative search.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Data Structures · Core
Balanced construction is a k-d tree build strategy that controls depth with median splits.
Compare with thisData Structures · Core
k-d trees split by coordinate axes, while quadtrees split space into fixed quadrants.
Compare with thisData Structures · Core
Range trees and k-d trees are alternative multidimensional indexing structures with different storage and range-query tradeoffs.
Compare with thisData Structures · Core
Spatial hashing and k-d trees are alternative spatial indexing strategies for nearby-object lookup.
Compare with thisk-d trees split by coordinate axes, while quadtrees split space into fixed quadrants.