What is it called when you organize a grid of sequential integers in a way that any range within that sequence is clustered together?

13 Views Asked by At

I have tried hard to search for this and I'm starting to think I am imagining that it exists. I may have come across this in an old XKCD comic. Imagine crumpling up a number line on a 2d plane. The goal of this format is to keep numbers that are close in value to be close in proximity to each other. I know my example is not going to be perfect, since I don't know the name or exactly how it is done. Any help would be appreciated.

Examples of wrong formats: If you chose the range of 4-6, to group these together you would have to wrap to the new line

1  2  3  4
5  6  7  8
9  10 11 12
13 14 15 16

This spiral seems a little better, but if you wanted to choose 2-9, it would be a donut shape around the 1.

13 14 15 16
12  3  4  5
11  2  1  6
10  9  8  7

The format I am looking for would probably end up more like this for the numbers 1-16. I kind of remember it snaking back and forth while kind of spiraling out from the middle.

7   6  1  2
8   5  4  3
9  10 11 12
16 15 14 13
1

There are 1 best solutions below

0
On BEST ANSWER

It's a variant of the Hilbert R-tree, which is related to the Hilbert curve.