# BSP Trees as a Multi-Dimensional Search Structure

Data Structure AlgorithmsAnalysis of AlgorithmsAlgorithms

Spatial search structures are based on the same ideas that were invented in Computer Science during the 60's and 70's for solving the problem of quickly processing large sets of symbolic data, as opposed to geometric data, for example lists of people's names. It was invented that by first sorting a list of names according to alphabet, and storing the sorted list in an array, one can compute whether some new name is already in the list in log2n operations using a binary search algorithm, rather than n/2 expected operations required with the help of a sequential search. This is a good example to extract structure (alphabetical order) existing in the list of names and exploiting that structure in subsequent operations (looking up a name) to decrease computation.

However, if one wishes to allow additions and deletions of names while maintaining a sorted list, then a dynamic data structure is required, i.e. one implementing pointers. One of the most common examples of such a data structure is nothing but a binary search tree.

In case of a binary search tree, where it is being implemented to represent a set of integer such as A = {1, 2, 5, 6, 7, 9} lying on the real line. To compute whether a number/point is already in the tree, one is able to insert the point into the tree and to follow the path corresponding to the sequence of nested intervals that consists of the point. For a balanced tree, this process will consume no more than O(log n) steps; for in fact, we have performed a binary search, but one implementing a tree rather than an array. Now, the tree itself is able to encode a portion of the search algorithm since it decides the order in which the search advances.

This now bring us return to Partitioning Trees, they are treated as a generalization of binary search trees to dimensions > 1 i.e. multi-dimensional (in 1D, they are essentially same). In fact, building a Partitioning Tree can be imagined of as a geometric version of Quick Sort.

Changes (deletions and insertions) are achieved by merging trees, analogous to merging sorted lists in Merge Sort.

However, since points do not divide space for any dimension > 1, we must implement hyperplanes rather than points by which to subdivide.

Hyperplanes always subdivide or partition a region into two half spaces irrespective of the dimension.

Updated on 08-Jan-2020 10:50:45