Multi-dimensional data. Two important operations on multi-dimensional data include range searching and nearest neighbors queries. Instead of working with data that can be sorted on a line, our data can be located anywhere in a 2-d, 3-d, etc. space.
K-d Trees. K-d trees generalize binary search trees to multi-dimensional data. Each level of the tree splits on a different dimension, starting with the first dimension (e.g. x-coordinate), then the second dimension (e.g. y-coordinate), and so forth. Cycle back to the first dimension (e.g. x-coordinate) after exhausting all the dimensions in a datapoint. For example, at the root, everything to the left has an x-value less than the root x-value and everything to the right has a x-value greater than the root x-value. Then, on the next level, every item to the left of a node has a y-value less than the node’s y-value and everything to the right has a y-value greater than the node’s y-value.