All Topics  
Quadtree

 

   Email Print
   Bookmark   Link






 

Quadtree



 
 
A quadtree is a tree data structure in which each internal node has up to four children. Quadtrees are most often used to partition a two dimensional space by recursively subdividing it into four quadrants or regions. The regions may be square or rectangular, or may have arbitrary shapes. This data structure was named a quadtree by Raphael Finkel
Raphael Finkel

Raphael Finkel is an American computer science and a professor at the University of Kentucky. He compiled the first version of the Jargon File....
 and J.L. Bentley in 1974. A similar partitioning is also known as a Q-tree.






Discussion
Ask a question about 'Quadtree'
Start a new discussion about 'Quadtree'
Answer questions from other users
Full Discussion Forum



Encyclopedia


A quadtree is a tree data structure in which each internal node has up to four children. Quadtrees are most often used to partition a two dimensional space by recursively subdividing it into four quadrants or regions. The regions may be square or rectangular, or may have arbitrary shapes. This data structure was named a quadtree by Raphael Finkel
Raphael Finkel

Raphael Finkel is an American computer science and a professor at the University of Kentucky. He compiled the first version of the Jargon File....
 and J.L. Bentley in 1974. A similar partitioning is also known as a Q-tree. All forms of Quadtrees share some common features:
  • They decompose space into adaptable cells
  • Each cell (or bucket) has a maximum capacity. When maximum capacity is reached, the bucket splits
  • The tree directory follows the spatial decomposition of the Quadtree


Types

Quadtrees may be classified according to the type of data they represent, including areas, points, lines and curves. Quadtrees may also be classified by whether the shape of the tree is independent of the order data is processed. Some common types of quadtrees are:

The region quadtree

The region quadtree represents a partition of space in two dimensions by decomposing the region into four equal quadrants, subquadrants, and so on with each leaf node containing data corresponding to a specific subregion. Each node in the tree either has exactly four children, or has no children (a leaf node). The region quadtree is not strictly a 'tree' - as the positions of subdivisions are independent of the data. They are more precisely called 'trie
Trie

In computer science, a trie, or prefix tree, is an ordered tree data structure data structure that is used to store an associative array where the keys are usually string s....
s'.

A region quadtree with a depth of n may be used to represent an image consisting of 2n × 2n pixels, where each pixel value is 0 or 1. The root node represents the entire image region. If the pixels in any region are not entirely 0s or 1s, it is subdivided. In this application, each leaf node represents a block of pixels that are all 0s or all 1s.

A region quadtree may also be used as a variable resolution representation of a data field. For example, the temperatures in an area may be stored as a quadtree, with each leaf node storing the average temperature over the subregion it represents.

If a region quadtree is used to represent a set of point data (such as the latitude and longitude of a set of cities), regions are subdivided until each leaf contains at most a single point.

Point quadtree

The point quadtree is an adaptation of a binary tree
Binary tree

In computer science, a binary tree is a Tree in which each node has at most two child node. Typically the child nodes are called left and right....
 used to represent two dimensional point data. It shares the features of all quadtrees but is a true tree as the center of a subdivision is always on a point. The tree shape depends on the order data is processed. It is often very efficient in comparing two dimensional ordered data points, usually operating in O(log n)
Big O notation

In mathematics, big O notation describes the asymptotic analysis of a function when the argument tends towards a particular value or infinity, usually in terms of simpler functions....
 time.

Node structure for a point quadtree

A node of a point quadtree is similar to a node of a binary tree, with the major difference being that it has four pointers (one for each quadrant) instead of two ("left" and "right") as in an ordinary binary tree. Also a key is usually decomposed into two parts, referring to x and y coordinates. Therefore a node contains following information:

  • 4 Pointers: quad[‘NW’], quad[‘NE’], quad[‘SW’], and quad[‘SE’]
  • point; which in turn contains:
    • key; usually expressed as x, y coordinates
    • value; for example a name


Edge quadtree

Edge quadtree are specifically used to store lines rather than points. Curves are approximated by subdividing cells to a very fine resolution. This can result in extremely unbalanced trees which may defeat the purpose of indexing.

Some common uses of quadtrees

  • Image representation
    * Spatial indexing
    Spatial index

    Spatial indexes are used by spatial databases to optimize spatial query. Indexes used by non-spatial databases cannot effectively handle features such as how far two points differ and whether points fall within a spatial area of interest....
  • Efficient collision detection
    Collision detection

    In physical simulations, video games and computational geometry, collision detection involves algorithms for checking for collision, i.e. intersection, of two given solids....
     in two dimensions
  • View frustum culling of terrain data
  • Storing sparse data, such as a formatting information for a spreadsheet
    Spreadsheet

    A spreadsheet is a computer application that simulates a paper worksheet. It displays multiple cells that together make up a grid consisting of rows and columns, each cell containing either alphanumeric text or numeric values....
     or for some matrix calculations
  • Solution of multidimensional fields
    Field (physics)

    In physics, a field is a physical quantity associated to each point of spacetime. A field can be classified as a scalar field, a vector field, or a tensor field, according to whether the value of the field at each point is a scalar , a vector , or, more generally, a tensor, respectively....
     (computational fluid dynamics
    Computational fluid dynamics

    Computational fluid dynamics is one of the branches of fluid mechanics that uses numerical methods and algorithms to solve and analyze problems that involve fluid flows....
    , electromagnetism
    Electromagnetism

    Electromagnetism is the physics of the electromagnetic field, a field which exerts a force on Elementary particles with the property of electric charge and which is reciprocally affected by the presence and motion of such particles....
    )


Quadtrees are the two-dimensional analog of octree
Octree

An octree is a tree data structure in which each internal node has up to eight children. Octrees are most often used to partition a three dimensional space by recursively subdividing it into eight octants....
s.

Caveats


If geometric subdividing fails to reduce the item count for each quadrant, (e.g., for overlapping data,) QuadTree subpartitioning fails, and the capacity must be breached for the algorithm to continue. For example, if the maximum capacity for a quadrant is 8, and there are 9 points at (0, 0), subpartitioning would produce three empty quadrants, and one containing the original 9 points, and so on. Because the tree must allow more than 8 points in such a quadrant, QuadTrees can approach O(N) complexity for data sets with arbitrary geometry (e.g., maps or graphs).

See also

  • Octree
    Octree

    An octree is a tree data structure in which each internal node has up to eight children. Octrees are most often used to partition a three dimensional space by recursively subdividing it into eight octants....
  • Binary space partitioning
    Binary space partitioning

    Binary space partitioning is a method for recursively subdividing a Euclidean space into convex sets by hyperplanes. This subdivision gives rise to a representation of the scene by means of a Tree known as a BSP tree....
  • Kd-tree
    Kd-tree

    In computer science, a kd-tree is a space partitioning data structure for organizing Point s in a k-dimensional Euclidean space. kd-trees are a useful data structure for several applications, such as searches involving a multidimensional search key ....
  • R-tree
    R-tree

    R-trees are tree data structures that are similar to B-trees, but are used for spatial indexs i.e., for indexing multi-dimensional information; for example, the coordinates of geographical data....
  • UB-tree
    UB-tree

    The UB-tree as proposed by Rudolf Bayer and Volker Markl is a balanced tree for storing and efficiently retrieving multidimensional data. It is basically a B+ tree with records stored according to Z-order , also called Morton order....
  • Spatial index
    Spatial index

    Spatial indexes are used by spatial databases to optimize spatial query. Indexes used by non-spatial databases cannot effectively handle features such as how far two points differ and whether points fall within a spatial area of interest....
  • Spatial database
    Spatial Database

    A spatial database is a database that is optimized to store and query data related to objects in space, including points, lines and polygons. While typical databases can understand various numeric and character types of data, additional functionality needs to be added for databases to process spatial data types....


External links