Efficient 2D spatial queries using recursive subdivision
A quadtree is a tree data structure where each node has exactly four children. It recursively subdivides 2D space into quadrants (NE, NW, SE, SW) to efficiently organize spatial data.
Click and drag to define a rectangular query region. The quadtree quickly finds all points within this region by pruning entire branches that don't intersect.
Algorithm: For each node, if the query region doesn't intersect the node's boundary, skip that entire subtree. This dramatically reduces the search space.
Checks every point
Prunes irrelevant branches
Watch particles move and collide. The quadtree dramatically reduces collision checks from O(n²) to O(n log n).