Portrait of the Hilbert Curve (2010)
corte.si
corte.si
I learned this has a technical name: the zigzag order is called “Boustrophedonic”, after the Ancient Greek tablets where they wrote right-to-left on one line, then left-to-right on the next. https://en.wikipedia.org/wiki/Boustrophedon
It totally depends on the specifics of your application, but a little while ago, I compared Hilbert to both Boustrophedonic and Morton order, and surprisingly, Boustrophedonic was the winner. My application was partitioning a 3d grid into blocks of active voxels where each block could be represented efficiently with only a range (pair) of indices. It’s surprising at first that the zig-zag sometimes has better locality than Hilbert or Morton.
The killer app was tape drives.
1. https://github.com/tidwall/bgen/blob/main/docs/SPATIAL_BTREE...
https://github.com/SchedMD/slurm/blob/abebf13e9009831376a2d7...
It greatly simplifies the job scheduler to cluster across index instead of some n-dimensional space when calculating placement in the cluster. Consider that each server in the cluster has multiple connections to other servers which all form a sort of hypercube with the Hilbert curve conceptually drawn inside it.
It also shows how simple the transpose operation can be. It's just a few loops and bit shifts.
And then as you let N grow, C tends to 1.
I believe the same is true for Morton, though the constant is larger. However, I think it is false for the zig-zag curve, with a counter-example being a long strip orthogonal to the usual direction of the zig-zag.