# Point Quadtrees in Data Structure

The point quadtree is an adaptation of a binary tree implemented to represent 2-dimensional point data. Features of all quadtrees is shared by point quadtree.

It is often very efficient in comparing 2-dimensional, ordered data points, usually executing in O(log n) time. Point quadtrees are valuable mentioning for completeness, but k-d trees surpass them as tools for generalized binary search.

Point quadtrees are built as follows.

Given the next point to insert, we compute the cell in which it lies and add it to the tree.

The new point is added such that the cell that contains it is divided into quadrants by the vertical and horizontal lines that run through the point. Consequently, cells are rectangular but not necessarily square.

In these trees, each node consists of one of the input points.

Since the division of the plane is determined by the order of point-insertion, the tree's height is sensitive to and dependent on insertion order. Inserting in an incorrect order can lead to a tree of height linear in the number of input points (at which point it becomes a linked-list).

If the point-set is static, pre-processing can be performed to build a tree of balanced height.

## Node structure for a point quadtree

A node of a point quadtree is same to a node of a binary tree, with the major difference being that it is associated with four pointers (each pointer is used for each quadrant) instead of two ("left" and "right") as in an ordinary binary tree. Also a key is usually broken into two parts, referring to x and y coordinates.

Therefore, a node consists of the following information