AlgoViz

Quadtrees for dense neighborhoods

medium 4 min

A point-region quadtree divides a region into four quadrants and recursively subdivides busy regions.

Video lesson · Chapter 1 of 5

The fifth restaurant arrives

0:00 / 3:29

The seventeenth charger splits the city block

1:16Reel

Theory

Read or listen first. About 1 min.

What it is

A point-region quadtree stores points in leaves. An overflowing leaf subdivides into four quadrants, and its points move into the appropriate children.

Split the crowded bucket

Western leaf · 16 chargers Eastern leaf · 2
This quadtree leaf can hold 16 chargers. The rural leaf to its east holds two. Both occupy the same area at this depth.

Why it exists

This concentrates index detail in a busy district. Sparse regions remain cheap to traverse, and queries can skip branches that lie outside the search area.

Words to know

Leaf capacity
The occupancy threshold used by a bucketed quadtree to decide whether to subdivide.

How it works

Step through the idea, or press Play.

Step 1 of 3

Fill a bucket. Sixteen chargers occupy a bounded district.

Understand it

Worked example

Quadtrees for dense neighborhoods in practice

A city district exceeds a bucket limit of sixteen chargers while an equally large rural quadrant holds two. Subdivide the city bucket. A query in the rural area can skip the entire city subtree.

Related case

Find every charger across a cell boundary

A driver near the edge of a grid cell requests chargers within 800 metres. The closest charger sits across the street in another cell.

Across the street, across the cell
Chargers on both sides of the streetABCOne cell misses charger B

Fetch intersecting cells and check candidates.

Sources