next up previous contents
Next: Deleting element from k-d Up: k-d Trees Previous: k-d Trees   Contents

Adding elements to k-d Tree

One adds a new point to a kd-tree in the same way as one adds an element to any other tree. First, traverse the tree, starting from the root and moving to either the left or the right child depending on whether the point to be inserted is on the ''left'' or ''right'' side of the splitting plane. Once you get to a leaf node, add the new point as either the left or right child of the leaf node, again depending on which side of the node's splitting plane contains the new point.

root 2006-04-11