Skip to content

Z-Order Curve

Linearize a quantized multidimensional grid by interleaving coordinate bits into a Morton code, making every quadtree or octree cell a contiguous one-dimensional key interval while preserving locality imperfectly.

Version
v3 · 2026-09-06 · History
Domain-specific #
3136
Origin domain
computer science
Subdomain
spatial data structures
Aliases
Morton order, Morton code, Z-curve, Lebesgue curve, Bit-interleaved order

Core Idea

The Z-order curve maps a quantized point \((x_0,\ldots,x_{d-1})\) to one scalar key by interleaving the coordinates' binary digits from most to least significant. In two dimensions, alternating (x)- and (y)-bits produces a Morton code; sorting these codes visits recursively nested quadrants in a Z-shaped order.

The decisive invariant is hierarchical: all points inside an aligned quadtree or octree cell share a bit prefix and therefore occupy a contiguous Morton-code interval. This lets ordinary one-dimensional arrays, B-trees, or hash partitions carry multidimensional hierarchy. Locality is useful but not perfect: nearby points are often close in order, while some cell boundaries create large key jumps.

Scope of Application

Morton order supports spatial databases, tiled maps, linear quadtrees and octrees, GPU texture swizzling, N-body partitioning, mesh ordering, sparse matrices, cache-aware matrix traversal, and distributed spatial decomposition. Morton's original file-sequencing proposal targeted geodetic data.

Its usefulness depends on coordinate scaling, dimension, query shape, precision, and workload. High dimensions dilute locality, and arbitrary range queries may fragment into many key intervals.

Clarity

State dimension, bit width, coordinate normalization, interleave order, endianness, signed encoding, and whether keys are truncated. Distinguish ordering from the drawn curve. For query claims, report interval-generation and false-positive behavior rather than saying only that locality is “preserved.”

Manages Complexity

Z-order compiles multidimensional hierarchy into a sortable scalar. Existing one-dimensional storage systems can then perform prefix scans, partitioning, merge, predecessor search, and bulk loading without pointer-rich tree nodes. The representation trades exact metric neighborhood for cheap hierarchy-aware locality.

Abstract Reasoning

  1. Normalize every coordinate to a fixed nonnegative integer range.
  2. write each coordinate in equal-width binary.
  3. Interleave bits by significance and dimension.
  4. Interpret the result as a scalar key.
  5. Sort or index records by that key.
  6. Translate hierarchical cells to prefix intervals.
  7. Decompose range queries or jump to the next admissible key.
  8. Measure locality and interval fragmentation against alternatives.

Knowledge Transfer

The portable pattern is encode several coordinates by interleaving their hierarchical address digits so common coarse location becomes a common scalar prefix. It transfers to sharding, cache layout, hierarchical identifiers, and multiresolution storage. The proposed immediate parent is Space-Filling Curve.

Relationships to Other Abstractions

Local relationship map for Z-Order CurveParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Z-Order CurveDOMAINDomain-specific abstraction: Space-Filling Curve — is a kind ofSpace-FillingCurveDOMAIN

Current abstraction Z-Order Curve Domain-specific

Parents (1) — more general patterns this builds on

  • Z-Order Curve is a kind of Space-Filling Curve Domain-specific

    Space-Filling Curve is the proposed immediate parent.

Hierarchy paths (3) — routes to 3 parentless roots

Neighborhood in Abstraction Space

Z-Order Curve sits in a sparse region of the domain-specific corpus (92nd percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.

Family — Unclustered & Miscellaneous (1565 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-09-08