Quadtree: Hierarchical Spatial Data Structure
- A quadtree is a hierarchical spatial data structure that recursively divides a 2D spatial region into four subregions, with each region represented by internal nodes and leaf nodes determined by application-specific stopping criteria, such as spatial homogeneity or boundaries.
- Applications of quadtrees include spatial indexing, computational geometry, adaptive numerical simulation, and numerous computational fields. Real-world use cases also steer examples for navigating, partitioning, robot navigation and beyond. Techniques to refine regions and optimize properties include adaptive resolution, hierarchical grids, balancing, and dynamic maintenance.
- Properties and characteristics of quadtrees include adaptability, efficient spatial localization, and representation, and several trade-offs between resolution and storage, adaptivity and regularity, compression and alignment, and more. Usage of quadtrees in machine learning and new techniques across a variety of fields yield improved techniques for boundary fidelity, resolution, and geometric shape use and refinement.
- follow_up_questions
A quadtree is a hierarchical spatial data structure that recursively decomposes a two-dimensional region into four subregions. An internal node represents a spatial region and has four children corresponding to its quadrants; a leaf represents a region that satisfies an application-specific stopping criterion, such as spatial homogeneity, a population threshold, bounded record count, or minimum geometric resolution. Quadtrees support adaptive resolution: large cells represent homogeneous or sparsely populated areas, while dense, heterogeneous, or geometrically complex areas are refined into smaller cells. The same principle appears in spatial indexing, computational geometry, numerical simulation, finite-element analysis, computer vision, machine learning, robotics, image compression, and parallel computing.
1. Definition, structure, and fundamental variants
Let the root region be
A conventional quadtree divides a region at its horizontal and vertical midpoints. If
the four child regions are
The children are spatially disjoint except for shared boundaries and collectively cover the parent. In two dimensions, each refinement multiplies the number of potential cells by four. At depth , a complete regular hierarchy contains cells at that level. A point is routed by comparing its coordinates with the current region midpoint, producing a sequence of quadrant decisions.
The term quadtree encompasses several related structures:
- Region quadtrees: the hierarchy is determined by a fixed spatial partition, and leaves represent regions. Quadboost uses this form for concurrent dictionary operations; internal nodes represent regions, while leaves contain keys and values (Zhou et al., 2016).
- Point quadtrees: the hierarchy can depend on inserted points and is commonly used for spatial organization of point sets.
- Bucketing quadtrees: leaves store records until a capacity threshold is exceeded, after which the region is subdivided.
- Compressed quadtrees: unary paths through empty regions are replaced by compressed links or nodes, reducing the representation to linear size in the number of points (Löffler et al., 2012).
- Balanced or smooth quadtrees: neighboring cells are constrained to have comparable sizes, commonly through a $2:1$ rule.
- Adaptive quadtrees: refinement is controlled by data, geometry, error, visual complexity, or a task-specific criterion rather than by uniform subdivision.
- Quadtree-like median partitions: recursive partitions use data-dependent medians rather than equal geometric midpoints. Such structures are not strict textbook quadtrees, but preserve the hierarchical spatial interpretation (Schiappacasse-Ulloa et al., 2023).
The stopping criterion determines the semantics of a leaf. In image representations, a region may remain a leaf when its pixels have sufficiently similar values. In spatial indexing, subdivision may stop when a bin contains no more than MaxBinRecords. In finite-element meshing, refinement may stop when seed-point or balance conditions are satisfied. In electoral districting, a region becomes a constituency when its population is below a threshold (Kale et al., 2024).
A quadtree can also be generalized to dimensions. A -dimensional cell has 0 children; the three-dimensional analogue is commonly called an octree. Dynamic smooth compressed quadtrees use the term quadtree uniformly across fixed dimensions and obtain 1-way subdivision in 2 (d. et al., 2017).
2. Spatial indexing, compression, and dynamic maintenance
The principal algorithmic advantage of a quadtree is direct spatial localization combined with adaptive refinement. A regular grid provides constant-time coordinate-to-cell mapping, but allocates resolution uniformly. A quadtree preserves hierarchical spatial organization while concentrating cells where records are dense or queries require greater precision.
A hybrid hierarchical grid can generalize the conventional 3 subdivision. If a region is divided into 4 horizontal and 5 vertical bins, a point can be mapped arithmetically to
6
where
7
For fixed 8 and 9, this mapping is 0. The resulting structure is a conventional bucketing quadtree when 1 at every level, but becomes a more general hierarchical grid when more divisions are used. The image-based hierarchical spatial index described in (0705.0204) stores record lists in nonempty cells, uses null for empty cells, recursively refines dense bins, and constructs a secondary grid in which empty cells reference lists associated with nearby records. These fallback references induce data-dependent, nonrectangular effective regions.
For uniformly distributed data with 2 records and 3 and 4 grid divisions, the expected number of records in one cell is
5
A nearest-neighbor query can inspect the query cell and its eight neighboring cells, giving the estimate
6
The hierarchical version subdivides a bin when its record count exceeds MaxBinRecords and stops when either the threshold is met or the bin reaches SmallestBinDimension. The latter condition is necessary for coincident points, which cannot be separated by geometric subdivision indefinitely. The implementation uses proxy collections containing record identifiers rather than copying records into child indexes.
Compression addresses a different problem: a regular quadtree can become unnecessarily deep when the point-set spread is large. If a compressed node 7 has one child 8 satisfying
9
and the region 0 contains no points, the intervening empty path can be represented by one compressed link. A compressed quadtree has size 1 for a planar point set of 2 points. Löffler and Mulzer prove that compressed quadtrees and planar Delaunay triangulations can be transformed into one another deterministically in 3 time on a pointer machine (Löffler et al., 2012). Their reduction from a compressed quadtree to a Delaunay triangulation proceeds through a well-separated pair decomposition, a linear-size supergraph containing the Euclidean minimum spanning tree, extraction of the EMST, and reconstruction of the Delaunay triangulation.
Dynamic maintenance must address balancing, compression, alignment, and concurrent modification. Dynamic smooth compressed quadtrees maintain split and merge operations in dimension-dependent worst-case time. For fixed dimension 4, the uncompressed smooth extension requires 5 operations per split or merge. Compressed-component insertion and deletion have bounds involving factors such as
6
Once the containing cell is known, structural point updates are worst-case constant time for fixed 7 and fixed compression parameter 8; arbitrary point insertion still requires 9 point location (d. et al., 2017).
Quadboost applies non-blocking concurrency to a region quadtree. It uses operation descriptors for substitution, compression, and atomic movement. Logical removal is separated from physical compression, and continuous search allows a failed update to resume from a valid ancestor instead of restarting at the root. Its move operation uses an LCA-based search and flags both source and destination parents in a globally consistent spatial order. The reported experiments evaluated 32 hardware threads; retrieval improvement reached 109% over a compared concurrent baseline, and move improvement reached 47% (Zhou et al., 2016).
3. Balancing, numerical discretization, and geometric computation
Adaptive refinement creates interfaces between cells of different sizes. Without balancing, a single coarse cell may border many levels of smaller cells, complicating neighborhood queries, numerical stencils, finite-element conformity, and parallel communication. A balanced or restricted quadtree constrains neighboring cells to differ by at most one refinement level, commonly expressed as
0
Dynamic smooth quadtrees use a layered branding construction to prevent long balancing cascades. True cells have brand 1, cells introduced to balance them have brand 2, and so on through brand 3. The resulting extended tree has linear size in the underlying tree for fixed dimension and achieves a constant-factor smoothness guarantee (d. et al., 2017).
In adaptive numerical simulation, quadtrees provide the geometric hierarchy for multigrid and adaptive mesh refinement. A geometric multigrid library for quadtree and octree grids uses cell-centered unknowns, five-point stencils in two dimensions, seven-point stencils in three dimensions, one layer of ghost cells, and 4-balanced blocks. The application AMR hierarchy is augmented with additional coarser solver levels so that the multigrid hierarchy reaches a small coarse problem. Restriction, prolongation, coarse–fine ghost exchange, and buffered MPI communication are defined directly on the block hierarchy. The implementation supports Cartesian two- and three-dimensional geometries, axisymmetric cylindrical geometry, periodic, Dirichlet, and Neumann boundary conditions, and free-space conditions for three-dimensional Poisson problems. Scaling results were reported up to 1792 cores (Teunissen et al., 2019).
Quadtrees also support finite-element discretizations in which hanging nodes arise naturally. In a quadtree mesh, a coarse edge can be covered by several edges of finer neighboring cells. The virtual-element flux-recovery method in (Cao, 2020) treats each rectangular cell with hanging nodes as a polygon for flux recovery. The recovered flux belongs to an 5-conforming virtual element space, so normal-flux continuity is imposed across subedges without ad hoc hanging-node constraints. Its local recovery uses weighted averages of neighboring numerical fluxes, local divergence conditions, polynomial projection, and stabilization. The resulting estimator is locally efficient and globally reliable under bounded mesh irregularity and coefficient quasi-monotonicity.
A related scaled-boundary finite-element method treats final quadtree cells—including cells with hanging nodes, trimmed boundary cells, and crack cells—as polygonal SBFEM cells. Boundary edges are discretized independently with linear, quadratic, or higher-order one-dimensional elements. Hanging nodes become ordinary boundary nodes; no transition elements, special constraints, or displacement interpolation are required. Curved boundaries are handled through trimming, projection of near-boundary vertices, and high-order boundary interpolation. Crack-tip singularities are represented by SBFEM radial eigenmodes rather than quarter-point elements or XFEM enrichment. The method was demonstrated on circular holes, multiple cracks, intersecting cracks, and a reactor-like geometry (Man et al., 2014).
Quadtrees are also relevant to proximity structures. A compressed quadtree can generate a well-separated pair decomposition of linear size. For a fixed 6, a pair 7 is well-separated when
8
The resulting WSPD supports sparse geometric graphs and proximity computations. In the planar case, it suffices to recover the EMST, because
9
This gives the deterministic linear-time equivalence between compressed quadtrees and Delaunay triangulations established in (Löffler et al., 2012).
Quadtrees can additionally serve as models of spatially embedded networks. The random road-network quadtree begins with a square tract and repeatedly selects an available square, inserts a horizontal and vertical road through its center, and replaces the selected square with four congruent children. The parameter 0 controls the qualitative spatial tendency: 1 favors larger squares and produces more sprawling development, while 2 favors smaller squares and produces denser local clustering. The resulting planar, axis-aligned network has a random multiscale structure and is intended for analysis of shortest paths and maximum flow (Eisenstat, 2010).
4. Quadtrees in image representation and machine learning
In image processing, a quadtree provides a variable-resolution representation. Homogeneous image regions can be represented by large leaves, while boundaries and textures are recursively refined. This principle has been used both for explicit image representations and as a routing mechanism for neural computation.
Quadtree Generating Networks represent semantic segmentation masks as compressed hierarchical trees instead of dense pixel grids. A node stores a level, spatial location, and semantic value; an additional composite value denotes a region containing multiple classes. Target masks are encoded using complete tree pyramids. A 3 patch is merged into one parent value if its four labels agree; otherwise, the parent receives the composite label. The network predicts coarse labels first and refines only composite regions. Sparse activations are stored as hash tables, and submanifold sparse convolutions operate only on active sites. On Cityscapes, the reported low-memory configuration used 3.66 GB and 0.25 TFLOPs with 73.0% mIoU, while the all-resolution configuration used 5.85 GB and 0.48 TFLOPs with 78.2% mIoU (Chitta et al., 2019).
QuadTree Attention applies the same coarse-to-fine principle to transformer attention. A token pyramid is constructed, and each query selects the top 4 coarse key regions. At the next level, attention is evaluated only among descendants of those selected regions. If 5 is constant, the attention computation is 6, hence 7, rather than 8. QuadTree-A recursively propagates attention scores, while QuadTree-B computes multilevel partial messages and combines them with learned weights. The method was evaluated in feature matching, stereo, image classification, object detection, and semantic segmentation. On FlyingThings3D, QuadTree-B reduced reported FLOPs from 490 G to 254 G and memory from 8507 MB to 5381 MB relative to the standard-transformer STTR configuration (Tang et al., 2022).
Point-query quadtrees adapt the number of crowd-counting queries to spatial density. An initial sparse point grid is refined where a learned split map identifies dense regions. Each selected query point can split into four child points, producing a variable number of queries. The split map is generated using average pooling, a 9 convolution, and a sigmoid, with test-time threshold 0. PET uses these point queries for classification and localization, predicts point offsets, and counts positive queries. The reported MAE was 49.34 on ShanghaiTech Part A and 79.53 on UCF-QNRF, with the point-query quadtree outperforming sparse-only and dense-only query configurations (Liu et al., 2023).
Quadtree-guided diffusion uses a low-resolution image to identify regions requiring expensive super-resolution refinement. QDM computes a max–min range over pooling windows:
1
where 2 is max pooling of the image and 3 is max pooling of its negation. The mask is
4
The upstream stream processes the complete image with coarse 5 patches; the downstream stream processes only 6-patch windows overlapping active mask regions. On Med-SR8, increasing the threshold to 7 reduced reported computation from 18.32 T MACs to 2.84 T MACs, with a PSNR decrease from 33.06 to 32.67 (Yang et al., 15 Mar 2025).
Quadtree-like median partitions provide fixed-length, permutation-invariant features for color–magnitude diagrams. Rather than splitting at geometric midpoints, the method recursively partitions at local medians, alternating between color and magnitude. A depth producing seven features yields one global median, two second-level medians, and four third-level medians. The features are robust to catalog permutation and moderate contamination. On a 56-cluster globular-cluster dataset, a linear regression using seven features achieved reported scatter of 0.16 dex for metallicity and 0.33 mag for distance modulus (Schiappacasse-Ulloa et al., 2023).
QuadTok extends the principle to visual tokenization. It uses a content-adaptive quadtree in which visually complex regions are expanded according to reconstruction benefit measured with Region-Wise Complexity Guidance. A region is expanded when the improvement in LPIPS reconstruction exceeds 8. The tree is serialized breadth-first, and topology-aware kinship masking preserves parent–child and sibling relationships. The default two-level representation uses 64 coarse regions and four children for each expanded region, giving
9
The ImageNet-trained tokenizer used approximately 230 tokens on average compared with a fixed 256-token grid, while the 947M-parameter QuadTok-XXL generator achieved 2.08 gFID on ImageNet $2:1$0 (Mao et al., 7 Oct 2026).
A different fixed-depth use appears in Quad-DeepSC, where the latent feature map is divided into four channel groups and processed in four quadtree-derived stages. The structure is used consistently for entropy estimation and wireless feature coding. The resulting Quad-LIC codec achieved a reported CLIC2021 BD-rate of $2:1$1 relative to VTM, while Quad-DeepSC achieved BD-CBR $2:1$2 relative to VTM plus 5G LDPC under AWGN at 10 dB (Huang et al., 5 Dec 2025).
5. Engineering, robotics, and application-specific formulations
The quadtree paradigm is widely adapted by changing the payload stored at each node and the criterion used for refinement.
In geographic and electoral partitioning, a node stores population information. A region is recursively divided whenever its population exceeds a threshold $2:1$3:
$2:1$4
Leaves satisfying $2:1$5 represent constituencies. Sibling leaves may be merged when their combined population remains below the threshold. The resulting structure supplies both seat counts and explicit geographic boundaries. The approach is best understood as a structured districting baseline: the paper does not provide a complete optimization objective, formal compactness metric, or rigorous guarantee of contiguity and freedom from gerrymandering (Kale et al., 2024).
In robot navigation, a quadtree compresses an occupancy map. Homogeneous free or occupied regions become leaves; mixed regions are subdivided until homogeneity or a minimum resolution $2:1$6 is reached. Free leaves are merged where adjacent union remains an axis-aligned rectangle, then organized into a connectivity graph. A sequence of connected free rectangles forms a safe corridor. Each rectangle becomes a set of linear inequalities:
$2:1$7
The same regions are used for graph planning, waypoint generation, B-spline smoothing, and model predictive control. In the reported static-map experiments, the safe-area MPC pipeline achieved 100% success in single-rectangle, double-rectangle, U-shaped, V-shaped, and complex mixed scenes, whereas the baseline MPC failed in the U-shaped, V-shaped, and complex scenes (Ali et al., 17 Nov 2025).
In mechanical design, the quadtree is not merely a computational mesh. Its edges are interpreted as physical structural elements. Continuous refinement variables $2:1$8 are assigned at multiple hierarchy levels, and a differentiable minimum-like filter enforces the parent–child dependency. The resulting finite-element density is
$2:1$9
Compliance minimization, SIMP penalization, Heaviside projection, and MMA optimization produce nearly binary adaptive structures. The method outperformed uniform and greedy quadtree patterns in the reported cantilever, MBB beam, curved bracket, and lightweight infill experiments (Wu, 2017).
In wireless semantic communication and learned compression, the hierarchy is not necessarily adaptively stopped by image content. Quad-DeepSC uses four fixed stages, while other systems such as QDM and QuadTok use image-dependent refinement. This distinction is important: “quadtree” may refer either to a conventional recursive spatial partition or to a fixed hierarchical schedule inspired by four-way spatial subdivision.
Quadtrees also serve as interconnection-network guests. The particular sub-quadtree 0 removes one child at every subdivision and therefore has three children per internal node:
1
The paper embeds 2 injectively into an 3-dimensional crossed cube 4, routing every guest edge with at most two host edges. The result is a one-by-one dilation-two embedding, designed for simulating quadtree communication on a parallel interconnection network (Selmi et al., 2022).
6. Properties, trade-offs, and limitations
The main strength of a quadtree is adaptive spatial resolution. Compared with a uniform grid, it reduces representation and computation in homogeneous areas while retaining fine resolution near boundaries, clusters, obstacles, or high-error regions. Compared with an unstructured point set, it provides containment, scale, neighborhood, and parent–child relationships. Compared with a strict 5 tree, generalized hierarchical grids can use more divisions per level and reduce tree depth at the expense of increased per-node storage.
The principal trade-offs are:
- Resolution versus storage: more divisions per layer reduce depth but increase grid and list-reference overhead.
- Adaptivity versus regularity: irregular refinement captures data structure efficiently but creates hanging nodes, coarse–fine interfaces, and more complex neighbor operations.
- Compression versus alignment: compressed links reduce space but complicate dynamic updates and geometric alignment.
- Locality versus global coverage: hierarchical queries can prune large regions, but nearest-neighbor and range queries may still require neighboring branches or edge scans.
- Accuracy versus sparsity in learned systems: aggressive pruning reduces memory and computation but can omit fine-scale information.
- Geometric simplicity versus boundary fidelity: axis-aligned cells are easy to process but can approximate curved, diagonal, or irregular boundaries conservatively.
- Update cost versus consistency: dynamic and concurrent variants require balancing, descriptors, helping, compression, and memory reclamation.
Quadtrees are not universally optimal. Highly fragmented images, spatial distributions with weak locality, coincident points, rapidly changing datasets, and domains dominated by irregular boundaries can reduce their advantages. A quadtree does not automatically guarantee balanced populations, compact districts, collision-free execution under model uncertainty, or preservation of fine visual detail. Those properties depend on the application-specific stopping rule, balancing condition, payload summaries, refinement policy, and downstream optimization.
The term also hides important distinctions. A strict quadtree has four congruent geometric children per internal node. A hierarchical grid may use more than four divisions per level. A compressed quadtree suppresses empty unary paths. A smooth quadtree constrains neighboring sizes. A quadtree-like machine-learning representation may use medians, learned masks, reconstruction benefit, or fixed-stage channel partitions instead of geometric midpoint subdivision. These structures share the principle of hierarchical spatial organization but differ in their geometry, invariants, update semantics, and computational guarantees.
Taken together, the research literature presents the quadtree as a general mechanism for transforming spatial heterogeneity into hierarchical computation. Its recurring pattern is
6
That pattern underlies spatial indexing, proximity algorithms, adaptive numerical methods, hierarchical vision models, semantic communication, robot navigation, districting, structural optimization, and parallel architecture mapping.