# Z-order (curve)

﻿
Z-order (curve)

Z-order, or Morton-order, first proposed in 1966 by G. M. Morton, [citation|first=G. M.|last=Morton|title=A computer Oriented Geodetic Data Base; and a New Technique in File Sequencing|series=Technical Report|publisher=IBM Ltd.|location=Ottawa, Canada|year=1966.] is a space-filling curve which is often used in computer science: Due to its good locality-preserving behaviour it is used in data structures for mapping multidimensional data to one dimension. The z-value of a point in multidimensions is simply calculated by interleaving the binary representations of its coordinate values. Once the data are sorted into this ordering, any one-dimensional data structure can be used such as binary search trees, B-trees, skip lists or (with low significant bits truncated) hash tables. The resulting ordering can equivalently be described as the order would get from a depth-first traversal of a quadtree; because of its close connection with quadtrees, the Z-ordering can be used to efficiently construct quadtrees and related higher dimensional data structures. [citation|first1=M.|last1=Bern|first2=D.|last2=Eppstein|authorlink2=David Eppstein|first3=S.-H.|last3=Teng|title=Parallel construction of quadtrees and quality triangulations|journal=Int. J. Comp. Geom. &amp; Appl.|volume=9|issue=6|pages=517–532|year=1999.]

Coordinate values

The figure below shows the Z-values for the two dimensional case with integer coordinates 0 ≤ "x" ≤ 7, 0 ≤ "y" ≤ 7 (shown both in decimal and binary). Interleaving the binary coordinate values yields binary "z"-values as shown. Connecting the "z"-values in their numerical order produces the recursively Z-shaped curve.

Use with one-dimensional data structures for range searching

Although well locality preserving, for efficient range searches an algorithm is necessary for calculating, from a point encountered in the data structure, the next Z-value which is in the multidimensional search range:

In this example, the range being queried (x=2..3, y=2..6) is indicated by the dotted rectangle. Its highest Z-value (MAX) is 45. In this example, the value F=19 is encountered when searching a data structure in increasing Z-value direction, so we would have to search in the interval between F and MAX (hatched area). To speed up the search, one would calculate the next Z-value which is in the search range, called BIGMIN (36 in the example) and only search in the interval between BIGMIN and MAX (bold values), thus skipping most of the hatched area. Searching in decreasing direction is analogous with LITMAX which is the highest Z-value in the query range lower than F. The BIGMIN problem has first been stated and its solution shown in [citation|url=http://www.vision-tools.com/h-tropf/multidimensionalrangequery.pdf|first1=H.|last1=Tropf|first2=H.|last2=Herzog|title=Multidimensional Range Search in Dynamically Balanced Trees|journal=Angewandte Informatik|volume=2|year=1981|pages=71–77.] . This solution is also used in UB-trees ("GetNextZ-address"). As the approach does not depend on the one dimensional data structure chosen, there is still free choice of structuring the data, so well known methods such as balanced trees can be used to cope with dynamic data (in contrast for example to R-trees where special considerations are necessary). Similarly, this independence makes it easier to incorporate the method into existing databases.

Applying the method hierarchically (according to the data structure at hand), optionally in both increasing and decreasing direction, yields highly efficient multidimensional range search which is important in both commercial and technical applications, e.g. as a procedure underlying nearest neighbour searches. Z-order is one of the few multidimensional access methods that has found its way into commercial database systems (Oracle database 1995 [citation|url=http://www-static.cc.gatech.edu/computing/Database/readinggroup/articles/p170-gaede.pdf|first1=Volker|last1=Gaede|first2=Oliver|last2=Guenther|title=Multidimensional access methods|journal=ACM Computing Surveys|volume=30|issue=2|pages=170–231|year=1998.] , Transbase 2000 [citation|url=http://www.mistral.in.tum.de/results/publications/RMF+00.pdf|first1=Frank|last1=Ramsak|first2=Volker|last2=Markl |first3=Robert|last3=Fenk |first4=Martin|last4=Zirkel |first5=Klaus|last5=Elhardt |first6=Rudolf|last6=Bayer |contribution=Integrating the UB-tree into a Database System Kernel|title=Int. Conf. on Very Large Databases (VLDB)|year=2000|pages=263–272.] ).

Already in 1966, G.M.Morton has proposed Z-order for file sequencing of a static two dimensional geographical database. Areal data units are contained in one or a few quadratic frames represented by their sizes and lower right corner Z-values, the sizes complying with the Z-order hierarchy at the corner position. With high probability, changing to an adjacent frame is done with one or a few relatively small scanning steps.

Related structures

As an alternative, the Hilbert curve has been suggested as it has a better order-preserving behaviour, but here the calculations are much more complicated, leading to significant processor overhead. BIGMIN source code for both Z-curve and Hilbert-curve were described in [citation|inventor-first=H.|inventor-last=Tropf|country-code=US|patent-number=7321890|title=Database system and method for organizing data elements according to a Hilbert curve|issue-date=January 22, 2008.] .

For a recent overview on multidimensional data processing, including e.g. nearest neighbour searches, see Hanan Samet's textbook [citation|first=H. |last=Samet|title=Foundations on Multidimensional and Metric Data Structures|publisher=Morgan-Kaufmann|location=San Francisco|year=2006.]

Applications in linear algebra

The Strassen algorithm for matrix multiplication is based on splitting the matrices in four blocks, and then recursively each of these blocks in four smaller blocks, until the blocks are single elements (or more practically: until reaching matrices so small that the trivial algorithm is faster). Arranging the matrix elements in Z-order then improves locality, and has the additional advantage (compared to row- or column-major ordering) that the subroutine for multiplying two blocks does not need to know the total size of the matrix, but only the size of the blocks and their location in memory.

References

* UB-tree
* Hilbert curve
* Hilbert R-tree
* Spatial index
* locality preserving hashing
* Matrix representation

Wikimedia Foundation. 2010.

### Look at other dictionaries:

• Z-order curve — Not to be confused with Z curve or Z order. Four iterations of the Z order curve …   Wikipedia

• second-order curve — antrosios eilės kreivė statusas T sritis fizika atitikmenys: angl. second order curve vok. Kurve zweiter Ordnung, f rus. кривая второго порядка, f pranc. courbe du second ordre, f …   Fizikos terminų žodynas

• Order (mathematics) — Contents 1 In algebra 2 In arithmetic 3 In analysis 4 …   Wikipedia

• Curve-billed Tinamou — Conservation status Least Concern (IUCN 3.1) …   Wikipedia

• Curve-billed Thrasher — Conservation status Least Concern ( …   Wikipedia

• Order — Or der, n. [OE. ordre, F. ordre, fr. L. ordo, ordinis. Cf. {Ordain}, {Ordinal}.] [1913 Webster] 1. Regular arrangement; any methodical or established succession or harmonious relation; method; system; as: (a) Of material things, like the books in …   The Collaborative International Dictionary of English

• Order book — Order Or der, n. [OE. ordre, F. ordre, fr. L. ordo, ordinis. Cf. {Ordain}, {Ordinal}.] [1913 Webster] 1. Regular arrangement; any methodical or established succession or harmonious relation; method; system; as: (a) Of material things, like the… …   The Collaborative International Dictionary of English

• Order in Council — Order Or der, n. [OE. ordre, F. ordre, fr. L. ordo, ordinis. Cf. {Ordain}, {Ordinal}.] [1913 Webster] 1. Regular arrangement; any methodical or established succession or harmonious relation; method; system; as: (a) Of material things, like the… …   The Collaborative International Dictionary of English

• Order of a differential equation — Order Or der, n. [OE. ordre, F. ordre, fr. L. ordo, ordinis. Cf. {Ordain}, {Ordinal}.] [1913 Webster] 1. Regular arrangement; any methodical or established succession or harmonious relation; method; system; as: (a) Of material things, like the… …   The Collaborative International Dictionary of English

• Order of battle — Order Or der, n. [OE. ordre, F. ordre, fr. L. ordo, ordinis. Cf. {Ordain}, {Ordinal}.] [1913 Webster] 1. Regular arrangement; any methodical or established succession or harmonious relation; method; system; as: (a) Of material things, like the… …   The Collaborative International Dictionary of English