ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Theory of external memory

The headers of include/ADS/external realize, beyond the book, the two-level memory of Aggarwal and Vitter and the algorithms that run in it, after chapters 1, Introduction, 4, List Ranking, and 5, Sorting Atomic Items, of Ferragina's book, i.e., the sorts by merging and by distribution with their lower bounds, the permutations and the ranking of a list. This page collects what the headers take for granted: the model and its notation (see Definitions and notation), the cost of the elementary patterns of access (see The patterns of access and their costs), and, for each family of algorithms, the property on which its correctness rests and the argument behind its bound (from Sorting to Ranking a list), and the files of records on the disk of the machine, on which the model meets the real one (see Files on the disk of the machine). The pseudocode of each algorithm is instead on the page of its header, in the comment of its function, together with the chapter of Ferragina's book, or the paper, that it follows.

Definitions and notation

The two-level memory has an internal memory of \( M \) items and a disk of unbounded size, divided into blocks of \( B \) consecutive items; an I/O moves one block between the disk and the memory, and the cost of an algorithm is the number of its I/Os, the computation in memory being free. An item is atomic: it is moved and compared whole, and a pair or a triple of the algorithms counts as one item. The model needs \( M \ge 2 B \), so that a block can be read while another is kept, and the algorithms of the area ask for \( M \ge 3 B \) (two inputs and an output) or more. TwoLevelMemory.h simulates it: every buffer is leased from a memory of \( M \) items, which a test reads back with its two counters of the I/Os, so that a bound of this page is checked on the run itself.

The symbols of the headers of the area
SymbolMeaning
\( n \), \( M \), \( B \)the items of the input, of the internal memory and of a block, with \( M \ge 2 B \) (memorySize(), blockSize())
\( \lceil n / B \rceil \)the blocks of a file of \( n \) items, the last one possibly partial (blocks())
\( \mathrm{scan}( n ) \), \( \mathrm{sort}( n ) \)\( \Theta( n / B ) \) and \( \Theta( ( n / B ) \log_{M / B} ( n / M ) ) \), the I/Os of a scan and of a sort of \( n \) items
\( R \), \( k \)the items of a run formed in memory, \( R = \lfloor M / B \rfloor B \), and the fan-in of a merge or the number of buckets of a distribution
\( \pi \)a permutation of \( 0 , \ldots , n - 1 \), with \( \mathit{out}[ i ] = \mathit{in}[ \pi( i ) ] \)
\( \mathit{succ}[ i ] \), \( r[ i ] \)the successor of the item \( i \) of a list, the tail \( t \) having \( \mathit{succ}[ t ] = t \), and its rank, the number of links from \( i \) to the tail
\( \tilde O( \cdot ) \)the bound up to the factor \( \log_{M / B} ( n / M ) \) of a sort, i.e., \( \tilde O( n / B ) = O( \mathrm{sort}( n ) ) \)

The patterns of access and their costs

An algorithm of the internal memory that follows links (a list, a tree of pointers, the edges of a graph) pays up to one I/O per link on the disk, since two consecutive links rarely fall in one block; the algorithms of the area replace such links by scans and sorts, whose blocks are read whole.

The patterns of access of the area and their I/Os
PatternI/OsRealization
scan of \( n \) items, read or written\( \lceil n / B \rceil \)DiskReader::next(), DiskWriter::push()
\( m \) reads at sorted positions\( \min\{ m , \lceil n / B \rceil \} \)DiskReader::at() with increasing positions
sort of \( n \) items\( \Theta( ( n / B ) \log_{M / B} ( n / M ) ) \)multiwayMergeSort(), distributionSort() (on average)
permutation of \( n \) items\( \Theta( \min\{ n , \mathrm{sort}( n ) \} ) \)permuteDirect() or permuteBySorting()
ranking of a list of \( n \) items\( \Theta( \mathrm{sort}( n ) ) \)externalListRank()

Reads at sorted positions share a block whenever two of them fall in it, since DiskReader loads a block only when it is not the one in its buffer; hence the coordinated scans of the algorithms (a sorted file of requests read together with the file that answers them) cost the scans of the two files, and no more.

Sorting

Theorem 1 (the lower bound of sorting). A sort by comparisons of \( n \) atomic items in the two-level memory needs, for some \( t \) reads,

\[ \binom{M}{B}^t ( B! )^{\lceil n / B \rceil} \ge n! , \quad \text{whence} \quad t = \Omega\Bigl( \frac{n}{B} \log_{M / B} \frac{n}{M} \Bigr) , \tag{1} \]

plus the \( \lceil n / B \rceil \) writes of the output (Aggarwal and Vitter).

Indeed, consider the tree of the executions, each node a read and its children the outcomes of the read. A read brings \( B \) items into a memory that holds \( M - B \) others, and what it can tell is the positions of the new items among the old ones, at most \( \binom{M}{B} \) outcomes, times the \( B! \) orders of the new items among themselves when the block is read for the first time, which happens \( \lceil n / B \rceil \) times. The leaves must tell apart the \( n! \) orders of the input, which gives (1); taking the logarithms, \( t \log \binom{M}{B} \ge n \log ( n / B ) - O( n ) \) and \( \log \binom{M}{B} = O( B \log ( M / B ) ) \), i.e., the bound of (1). sortingLowerBound() computes the least \( t \) with the logarithms of the factorials, so that a test can compare it with the I/Os counted.

A permutation is no easier, once the writes are counted too: a write can put its block in any of \( n + 1 \) places of the output, and the condition

\[ ( ( n + 1 ) \binom{M}{B} )^t ( B! )^{\lceil n / B \rceil} \ge n! \tag{2} \]

gives \( t = \Omega( \min\{ n , \mathrm{sort}( n ) \} ) \) (permutingLowerBound()): the minimum is \( n \), one read per item, only when \( B \) is smaller than the logarithm of the sort. Hence on the disk the cost of a sort is that of moving the items, not that of finding their order.

The mergesort reaches (1). Its first pass forms the runs, reading \( R \) items at a time and sorting them in memory, which saves the \( \log_2 M \) lowest levels of the recursion; each further pass merges groups of \( k \) runs with a block of each in memory and one for the output, and reads and writes every block once. With \( \lceil n / R \rceil \) runs, the I/Os are

\[ 2 \lceil n / B \rceil \bigl( 1 + \lceil \log_k \lceil n / R \rceil \rceil \bigr) , \tag{3} \]

the value of mergeSortIOs(). With \( k = 2 \) (binaryMergeSort()) this is \( O( ( n / B ) \log_2 ( n / M ) ) \), and with \( k = M / B - 1 \) (multiwayMergeSort()) it is \( O( ( n / B ) \log_{M / B} ( n / M ) ) \), i.e., optimal by (1). The choice of the least head among \( k \) runs costs no I/O, and a tree of losers makes it with \( \lceil \log_2 k \rceil \) comparisons, one per level on the path of the winner. Replacement selection (the snow plow of Knuth) forms longer runs with a heap of \( M - 2 B \) items: an item larger than the last one written joins the current run, a smaller one the next run; on a random input the runs have \( 2 ( M - 2 B ) \) items on average, which saves a pass when the number \( \lceil n / R \rceil \) of the runs of the other way lies roughly between a power \( k^p \) and \( 2 k^p \), and a sorted input is one run.

Lemma 2 (the sample of the distribution). Let the \( k - 1 \) pivots be the items of ranks \( ( a + 1 ) , 2 ( a + 1 ) , \ldots \) of a sorted random sample of \( ( a + 1 ) k - 1 \) items, with \( a + 1 = \lceil 12 \ln k \rceil \). Then with probability at least \( 1 / 2 \) every bucket between two consecutive pivots has fewer than \( 4 n / k \) items.

Indeed, cut the sorted input into \( k / 2 \) segments of \( 2 n / k \) items each: a bucket with \( 4 n / k \) items or more contains a whole segment, and then no more than \( a \) items of the sample fall in that segment, while \( 2 ( a + 1 ) \) are expected there; by a bound of Chernoff this has probability at most \( e^{- ( a + 1 ) / 6} \le k^{-2} \), and the union over the \( k / 2 \) segments gives at most \( 1 / 2 \).

Hence distributionSort() draws the sample again when a bucket is too large (at most twice), and with buckets of fewer than \( 4 n / k \) items the recursion has \( O( \log_{k / 4} ( n / M ) ) \) levels, each of which reads and writes every item once. The memory holds a block of the input, a block for each of the \( k \) buckets between the pivots and of the \( k - 1 \) buckets of the items equal to a pivot (which stop the recursion on repeated keys, as the three-way partition of quicksort does), a block of the output and the pivots; hence \( k = \lfloor ( M - B ) / ( 2 B + 1 ) \rfloor \), half the fan-in of the merge, and the same \( O( \mathrm{sort}( n ) ) \) I/Os on average.

The sorts of the area
SortMemoryI/OsRemarks
binaryMergeSort()\( M \ge 3 B \)\( O( ( n / B ) \log_2 ( n / M ) ) \)deterministic, the logarithm in base 2
multiwayMergeSort()\( M \ge 3 B \)\( O( \mathrm{sort}( n ) ) \)deterministic, optimal; fewer runs with the snow plow
distributionSort()\( M \ge 5 B + 2 \)\( O( \mathrm{sort}( n ) ) \) on averagerandomized, fan-in about half that of the merge

On \( D \) disks read in parallel, the striping (the \( D \) disks as one with blocks of \( D B \) items) turns either sort into one of \( O( ( n / D B ) \log_{M / D B} ( n / M ) ) \) I/Os, which loses a factor \( 1 - \log_{M / B} D \) in the base of the logarithm; Greed Sort of Nodine and Vitter recovers the optimum. The functions of the area simulate one disk.

Permuting

permuteDirect() reads \( \mathit{in}[ \pi( i ) ] \) for \( i = 0 , 1 , \ldots \) and writes the output by a scan: at most \( n \) reads, fewer when consecutive positions fall in one block. permuteBySorting() instead sorts the pairs \( \langle i , \pi( i ) \rangle \) by \( \pi( i ) \), fills in \( \mathit{in}[ \pi( i ) ] \) by one scan of the input, which is now read in order, and sorts the triples back by \( i \): two sorts and three scans, \( O( \mathrm{sort}( n ) ) \); by (2) the better of the two is optimal, the direct one only when \( B \) is below the logarithm of the sort.

Ranking a list

In memory a list is ranked in \( O( n ) \) time by a walk back from the tail (listRank()), which on the disk costs up to one I/O per item. The algorithms of the area avoid the walk in two ways, both from the parallel algorithms.

Lemma 3 (pointer jumping). Start from \( s[ i ] = \mathit{succ}[ i ] \), and \( r[ i ] = 1 \) but at the tail, where it is 0; if each round sets, for all the items at once,

\[ r[ i ] \gets r[ i ] + r[ s[ i ] ] , \qquad s[ i ] \gets s[ s[ i ] ] , \tag{4} \]

then after \( j \) rounds \( r[ i ] \) is the number of links from \( i \) to \( s[ i ] \), which is \( \min\{ 2^j , r( i ) \} \) away (Wyllie).

Indeed, (4) adds the length of the jump of \( s[ i ] \) to that of \( i \), and by induction on \( j \) both are \( 2^{j-1} \) unless the tail is reached. Hence \( \lceil \log_2 n \rceil \) rounds rank the list, with \( O( n \log n ) \) operations (listRankPointerJumping()). A round of (4) is a parallel step \( A[ a_i ] \gets \mathrm{op}( A[ a_i ] , A[ b_i ] ) \), and parallelStep() makes it on the disk by sorting the requests by \( b_i \), answering them by one scan of \( A \), sorting them back by \( a_i \) and applying them by a second scan; thus any parallel algorithm of \( T \) steps on \( n \) processors costs \( \tilde O( ( n / B ) T ) \) I/Os, and externalPointerJumping() \( \tilde O( ( n / B ) \log n ) \).

The logarithm goes away by recursion. If \( I \) is an independent set, i.e., no item of \( I \) is the successor of another item of \( I \) nor the tail, the items whose successor is in \( I \) can jump over it, adding its rank to their own; the remaining list is ranked recursively, and each item of \( I \) then gets the rank of its successor plus its own. With \( | I | \ge n / 8 \) and each level made of a constant number of sorts and scans (the joins of each record with the record of its successor),

\[ T( n ) = \tilde O( n / B ) + T( 7 n / 8 ) = \tilde O( n / B ) , \tag{5} \]

since the sizes of the levels decrease geometrically (externalListRank()). The independent sets come in two kinds.

The independent sets of the area
SetSizeRounds
randomIndependentSet(): a coin per item, the heads whose successor shows tails\( n / 4 \) on average, at least \( n / 8 \) after \( O( 1 ) \) attempts on average1
independentSetOfColors() on deterministicCoinTossing(): the local minima of three colorsat least about \( n / 4 \)\( O( \log^* n ) \)

An item enters the random set with probability \( 1 / 4 \) (its own coin heads, that of its successor tails), and two items of the set cannot be consecutive, since the successor of one shows tails. The deterministic coin tossing of Cole and Vishkin starts from the colors \( c[ i ] = i \), which differ on adjacent items, and replaces at each round \( c[ i ] \) by \( 2 \pi + z \), with \( \pi \) the lowest bit in which \( c[ i ] \) and \( c[ \mathit{succ}[ i ] ] \) differ and \( z \) the value of that bit in \( c[ i ] \).

Lemma 4 (deterministic coin tossing). If adjacent colors differ before a round, they differ after it, and colors of \( b \) bits become colors of \( \lceil \log_2 b \rceil + 1 \) bits.

Indeed, if \( i \) and its successor \( j \) get the same new color, they have the same \( \pi \) and the same bit \( \pi \); but \( \pi \) is a bit in which the old colors of \( i \) and \( j \) differ, a contradiction. The new color is at most \( 2 ( b - 1 ) + 1 \), which has \( \lceil \log_2 b \rceil + 1 \) bits. Hence after \( O( \log^* n ) \) rounds the colors are in \( \{ 0 , \ldots , 5 \} \), and the items of colors 5, 4 and 3 in turn take the least color of \( \{ 0 , 1 , 2 \} \) that neither neighbor has, which keeps the colors proper since the items of one color are not adjacent. The local minima of three colors are independent, and between two consecutive local minima there are at most 3 other items. listRankIndependentSet() runs the recursion in memory with either set; on the disk the deterministic sets would repeat the joins of their \( O( \log^* n ) \) rounds at every level, and the area uses them only in memory. The optimal parallel rankings of Cole and Vishkin and of Anderson and Miller use the same sets to reach \( O( n ) \) operations in \( O( \log n ) \) time, and on the disk \( \Theta( \mathrm{sort}( n ) ) \), the bound of (5), is optimal (Chiang et al.).

Files on the disk of the machine

The structures of the model keep their blocks in memory and count the I/Os, which is what the bounds of the area are stated in; an algorithm whose data do not fit in the memory of the machine needs instead files on its disk, and RecordFile.h gives the least of them that the scans and the sorts of this page need: a RecordFile of records of a trivially copyable type, written as their bytes, appended at its end and read in order, a RecordWriter that appends through a buffer of records, and a TempDirectory that holds the files of a run and is removed with them. With buffers of \( b \) records a scan of \( n \) records makes \( \lceil n / b \rceil \) reads of the system, so that \( b \) plays the part of \( B \) in the model; since a disk (and, to a lesser extent, an SSD) moves a large contiguous piece of a file much faster than as many small ones, the default buffer is of 1 MB, i.e., some hundreds of the blocks of the file system. A writer opens its file only to write a full buffer, and closes it after, so that a program may keep one writer for each of thousands of files (e.g., the buckets of a search with delayed duplicate detection, in which the successors of a bucket are distributed among the files of the buckets they belong to, as in the hash-based search of Korf), at the price of an opening of the file per buffer, which is small against the transfer of 1 MB. Unlike STXXL (Dementiev, Kettner and Sanders) the files have neither their own blocks nor asynchronous I/O, which leaves the caching to the operating system: the algorithms that use them read and write each file by long sequential scans, the pattern on which the cache and the read-ahead of the system are at their best.

Persistence and mapped files

A static structure (a succinct index, a filter, a minimal perfect hash function) is built once and queried many times, and Persistence.h writes it to a file by store() and reads it back by restore(), or maps the file by restoreMapped() [see MappedFile.h]. In the format, each array of numbers starts on a multiple of 64 bytes of the file, and its allocator (MappableAllocator, or the one of the words of a BitVector) returns the bytes of the mapping instead of new memory and constructs nothing over them. Hence a structure of \( k \) numbers and \( m \) arrays opens in \( O( k + m ) \) time, whatever the lengths of its arrays, and its pages are read at their first access, as the blocks of the model are read at their first I/O; the checks that need no scan of the arrays (the magic numbers, the sizes of the header, of the payload and of the trailer, and the invariants of the sizes) are made at once, while the checksum of the whole file is computed only by restore() or when asked.

The B-tree on the blocks of Morin's book

The BlockStore of chapter 14 of Morin's book (BlockStore.h) is the disk of the external memory model as an array of blocks, whose read and write are the I/Os, and the B-tree on it (BlockBTree.h) keeps in each node from \( B - 1 \) to \( 2 B - 1 \) keys, the root from 0 or 1, the leaves at one depth, so that a search reads \( O( \log_B n ) \) blocks.

Lemma 5 (the splits, merges and borrows of the B-tree). From the empty tree, \( m \) insertions and removals make at most \( 3 m / 2 \) splits, merges and borrows (Lemma 14.1 of Morin's book), and a sequence of two insertions and two removals at a leaf of \( 2 B - 2 \) keys makes a split, a borrow and a merge, so that \( \Theta( m ) \) is reached for any \( B \).

Indeed, keep one credit on each node but the root with \( B - 1 \) keys and three on each node with \( 2 B - 1 \) keys: each operation creates at most three, and two pay each restructuring. A split takes the three credits of its node, one for its new node of \( B - 1 \) keys and two for itself; a merge takes the credits of its two nodes of \( B - 2 \) and \( B - 1 \) keys; the borrow that ends a removal takes the credit of the node in underflow and one new credit, and two more new ones if both nodes are left with \( B - 1 \) keys (exercise 14.5 draws them on the figures). The cycle of the second claim is the test ods.ex14.6.restructures: the two insertions make a leaf of \( 2 B \) keys, split into \( B \) and \( B - 1 \), the first removal leaves \( B - 2 \) keys beside a sibling of \( B \), which lends one, and the second leaves \( B - 2 \) beside \( B - 1 \), which merges them back into a leaf of \( 2 B - 2 \) keys.

Lemma 6 (the restructurings far from the bounds). If every node that a restructuring writes has at least \( \alpha B \) keys more than its lower bound and fewer than its upper bound, for a constant \( \alpha > 0 \), then \( m \) operations make \( O( m / B ) \) restructurings.

Indeed, let the potential be \( \sum_u \max\{ 0 , \alpha B - d( u ) \} \), \( d( u ) \) the distance of the number of keys of \( u \) from its nearer bound: an operation changes the keys of one leaf by one, and each restructuring adds a key to the parent, both raising the potential by at most one per node touched; a restructuring of a node at its bound lowers the potential of that node by \( \alpha B \) and writes \( O( 1 ) \) nodes at potential 0, so that the restructurings are \( O( 1 / B ) \) of the units the operations bring. The policy WIDE (exercise 14.6) keeps \( B - 1 \) to \( 3 B - 1 \) keys, splits \( 3 B \) keys into two nodes of about \( 1.5 B \), merges a node in underflow with its sibling whenever the two have at most \( 2.5 B \) keys, before it is needed, the merged node having from \( 2 B - 2 \) to \( 2.5 B \) keys, and otherwise shares their keys at more than \( 1.25 B \) each; the policy THREE (exercise 14.7) keeps the bounds of the book and shares the keys of a node in overflow with a sibling into two nodes, if they can stay \( B / 4 \) below the top, or into three of about \( 4 B / 3 \), and those of a node in underflow with two siblings into two nodes or three in the same way, so that every node written has between about \( 7 B / 6 \) and \( 7 B / 4 \) keys. Both meet the condition, with \( \alpha = 1 / 4 \) and \( \alpha = 1 / 8 \) for \( B \ge 8 \), and the cycle of Lemma 5 costs them nothing after its first round. On a tree of two leaves, where its moves lack the siblings, THREE lets the leaves hold down to \( \lambda = \max( 1 , \lfloor B / 2 \rfloor ) \) keys; a leaf below \( \lambda \) is merged with the other one into a root leaf if that leaf has at most \( 2 B - 1 - \lfloor B / 4 \rfloor \) keys, and otherwise the two share their keys, more than about \( 7 B / 8 \) and at most about \( 5 B / 4 \) each. The split of a root leaf of \( 2 B \) keys gives two leaves of \( B \) and \( B - 1 \), about \( B / 2 \) above \( \lambda \), and the root leaf of a merge is \( B / 4 \) below the top; hence these nodes too are \( B / 8 \) from their bounds, the bound of a leaf changes only when a restructuring rewrites it (from two leaves to three, or back), and the cycle of Lemma 5 at a root leaf costs a single split. The internal children of a root of two children follow the rules of the book, but their keys change only by the restructurings below them, \( O( m / B ) \), and so do their restructurings.

Lemma 7 (the internal nodes). A B-tree of \( n \) keys whose root is not a leaf has at most \( ( ( n + 1 ) / B + B - 3 ) / ( B - 1 ) \) internal nodes, \( O( n / B^2 ) \) (exercise 14.3).

Indeed, with \( L \) leaves and \( I \) internal nodes, the internal nodes hold \( L - 1 \) keys (one fewer than their children, which are the \( I + L - 1 \) nodes but the root) and the leaves at least \( ( B - 1 ) L \), so that \( n \ge B L - 1 \); and the children are at least \( 2 + B ( I - 1 ) \), so that \( I \le ( L + B - 3 ) / ( B - 1 ) \).

The recursion of the code of the book holds a node per level while it goes back up, \( \Theta( B \log_B n ) \) words of internal memory, against the \( O( B + \log_B n ) \) that the introduction of the chapter claims (exercise 14.4): BlockBTree keeps the path as the indices of the blocks and of the children, \( O( \log_B n ) \) words, and at most five nodes at once, reading a parent again on the way up only when a restructuring or the successor of a removed key reaches it, which the amortized bound of Lemma 5 keeps at \( O( 1 ) \) reads per operation more than the descent. Exercises 14.1 and 14.2 are the test ods.ex14.1.figure, on the tree of figure 14.2, and exercise 14.8 is the removal of BPlusTree (see B-trees).

References

See also
P. Ferragina, Pearls of Algorithm Engineering, Cambridge University Press, 2023, chapters 1, Introduction, 4, List Ranking, and 5, Sorting Atomic Items, doi:10.1017/9781009128933
A. Aggarwal, J. S. Vitter, The input/output complexity of sorting and related problems, Communications of the ACM 31(9), 1116-1127, 1988, doi:10.1145/48529.48535
J. S. Vitter, External memory algorithms and data structures: dealing with massive data, ACM Computing Surveys 33(2), 209-271, 2001, doi:10.1145/384192.384193
D. E. Knuth, The Art of Computer Programming, vol. 3, 2nd ed., Addison-Wesley, 1998, sections 5.4.1 and 5.4.9
W. D. Frazer, A. C. McKellar, Samplesort: a sampling approach to minimal storage tree sorting, Journal of the ACM 17(3), 496-507, 1970, doi:10.1145/321592.321600
M. H. Nodine, J. S. Vitter, Greed Sort: optimal deterministic sorting on parallel disks, Journal of the ACM 42(4), 919-933, 1995, doi:10.1145/210332.210343
R. Dementiev, L. Kettner, P. Sanders, STXXL: standard template library for XXL data sets, Software: Practice and Experience 38(6), 589-637, 2008, doi:10.1002/spe.844
R. E. Korf, Linear-time disk-based implicit graph search, Journal of the ACM 55(6), 26:1-26:40, 2008, doi:10.1145/1455248.1455250
J. C. Wyllie, The complexity of parallel computations, PhD thesis, Cornell University, 1979
R. Cole, U. Vishkin, Deterministic coin tossing with applications to optimal parallel list ranking, Information and Control 70(1), 32-53, 1986, doi:10.1016/S0019-9958(86)80023-7
R. J. Anderson, G. L. Miller, Deterministic parallel list ranking, Algorithmica 6, 859-868, 1991, doi:10.1007/BF01759076
Y.-J. Chiang, M. T. Goodrich, E. F. Grove, R. Tamassia, D. E. Vengroff, J. S. Vitter, External-memory graph algorithms, Proceedings of the 6th ACM-SIAM Symposium on Discrete Algorithms (SODA), 139-149, 1995
P. Morin, Open Data Structures (in C++), Edition 0.1G, 2013, https://opendatastructures.org/ods-cpp.pdf, chapter 14
S. Huddleston, K. Mehlhorn, A new data structure for representing sorted lists, Acta Informatica 17(2), 157-184, 1982, doi:10.1007/BF00288968