liveBook · Manning

Balanced k-d tree construction

As explained in Advanced Algorithms and Data Structures

Balanced k-d tree construction is a recursive algorithm that selects coordinate-wise medians as pivots to build a balanced k-d tree.

Balanced k-d tree construction recursively chooses a coordinate-wise median as each pivot, then builds subtrees from the points on either side. The comparison coordinate advances with the recursion level, typically using level modulo k. section 9.3.3

The construction follows a small set of implementation steps:

  • Partition the points around a median using the coordinate selected by the current level. section 9.3.3

Two-dimensional partition

For eight points, choosing (-0.5, 0) as the first-coordinate median leaves four points on each side. The left subtree then partitions its three points by the second coordinate, choosing (-1, 1) as its median. section 9.3.3

How Advanced Algorithms and Data Structures covers it

How deep it goes
Explains recursive partitioning, base cases, alternating coordinates, and complexity, while stopping short of implementation language details.
Examples
Uses an eight-point two-dimensional dataset with successive x- and y-coordinate medians to demonstrate subtree construction.
What it assumes
Assumes recursive algorithms, arrays, medians, partitioning, and asymptotic notation; introduces coordinate selection through recursion levels.
What you can do after
Build it from scratch using recursive median selection, linear-time partitioning, and explicit level tracking.
How it connects
Connects medians, recursive partitioning, balanced trees, multidimensional data indexing, and k-d tree dimensions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.