VII · Spatial structures

Quad-tree / Octree

Recursive 4-way / 8-way subdivision.

The story

Recursively split 2D space (or 3D, for octree) into four (eight) equal quadrants. Each level halves resolution; deeper levels resolve dense regions. Used everywhere in graphics, physics simulation, and image processing.

How it works

Each node either stores the points in its quadrant directly (leaf), or has 4 children covering 4 sub-quadrants. Splits when point count exceeds a threshold. Search and insert recurse only into the relevant quadrants.

Where it lives

Image quadtree compression. Game-engine spatial partitioning. Procedural generation. Adaptive mesh refinement in physics simulations. Minecraft's chunk lookup uses something like an octree.

The key insight

Quadtrees adapt to data density — sparse regions stay shallow, dense regions get deeper. That's the property that makes them dominant in graphics and simulation.