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

The headers of include/ADS/search answer questions on a vector by looking at few of its items: the place of a key in a sorted vector (the binary search of section 1.2 of the book and the search by interpolation of section 12.1), the minimum and the local optima, the item of a given rank (the selection of section 17.1), and the minimum of any range of an array after a preprocessing, together with the engineered versions of these searches that count the misses of the cache and the branches that the processor mispredicts. This page collects what the headers take for granted: the definitions and the notation shared by all of them (see Definitions and notation), the lower bounds and the invariants of the searches in a sorted vector (see Searches in a sorted vector), the searches laid out for the memory (see Searches laid out for the memory), the minimum and the local optima (see The minimum and the local optima), the selection (see The selection), the range minima (see Range minima), and the PGM-index compressed and made dynamic (see The PGM-index compressed and dynamic). The pseudocode of each algorithm is instead on the page of its header, in the comment of its function, together with the section of the book, or the paper, that it follows.

Definitions and notation

The input is a vector \( A[ 0 .. n - 1 ] \) of items of a totally ordered universe, compared by an order less() (the operator \( < \) unless one is given); \( A \) is sorted if \( A[ i ] \le A[ i + 1 ] \) for every \( i \). A comparison is the evaluation of the order on two items, and the cost of a search is the number of its comparisons, the other operations being proportional to it, unless the comment of a function says otherwise. The rank of an item is its place in the sorted order, from 1 in Selection.h as in the book and from 0 in NthElement.h and SortedSearches.h as in the standard library.

The symbols of the headers of the area
SymbolMeaning
\( A[ i .. j ] \), \( A[ i .. j ) \)the items of the places from \( i \) to \( j \), with \( j \) and without it
\( \mathit{lo} \), \( \mathit{hi} \), \( m \)the ends of the part still to examine and its middle place, i.e., \( m = \mathit{lo} + \lfloor \Delta / 2 \rfloor \) with \( \Delta = \mathit{hi} - \mathit{lo} \)
\( \mathrm{lowerBound}( v ) \)the first place of an item not smaller than \( v \), \( n \) if none; \( \mathrm{upperBound}( v ) \) the first place of an item larger than \( v \)
\( \mathrm{RMQ}( i , j ) \)the place of the leftmost minimum of \( A[ i .. j ] \), \( i \le j \)
\( B \)the items in a line of cache of 64 bytes, e.g., 16 of 32 bits
\( \epsilon \), \( \epsilon_r \)the largest error, in places, of the lines of a learned index at its last level and at the others

A comparison-based search is a decision tree (section 2.7.4): a binary tree whose inner nodes are the comparisons and whose leaves are the answers, a run being the path from the root to a leaf, so that the worst case of the search is the height of its tree (decisionTree() of BinarySearch.h builds the tree of the binary search).

Searches in a sorted vector

Lemma 1 (the lower bound of the search). Every comparison-based search for the place \( \mathrm{lowerBound}( v ) \) in a sorted vector of \( n \) items makes, in the worst case,

\[ \lceil \log_2 ( n + 1 ) \rceil \tag{1} \]

comparisons at least.

Indeed, the answer is one of the \( n + 1 \) places \( 0 , \ldots , n \), each of which is the answer for some \( v \), and its decision tree has therefore \( n + 1 \) leaves at least; a binary tree of height \( h \) has at most \( 2^h \) of them, whence (1).

The binary search meets (1). lowerBound() keeps the invariant

\[ A[ \mathit{lo} - 1 ] < v \le A[ \mathit{hi} ] , \tag{2} \]

with \( A[ -1 ] = -\infty \) and \( A[ n ] = +\infty \), which holds at the start with \( \mathit{lo} = 0 \) and \( \mathit{hi} = n \); a comparison of \( v \) with \( A[ m ] \) moves one of the two ends to \( m \) or to \( m + 1 \) and keeps (2), and the length \( \mathit{hi} - \mathit{lo} \) goes from \( \ell \) to at most \( \lfloor \ell / 2 \rfloor \); hence the loop ends after \( \lceil \log_2 ( n + 1 ) \rceil \) comparisons with \( \mathit{lo} = \mathit{hi} \), which is the answer by (2). The binary search of the book (binarySearch()) stops as soon as it meets \( v \), at the price of two comparisons per step, and its decision tree has all its levels full but the last one, so that its height is \( \lfloor \log_2 n \rfloor \). The middle is computed as \( \mathit{lo} + \lfloor ( \mathit{hi} - \mathit{lo} ) / 2 \rfloor \), which never overflows, unlike \( ( \mathit{lo} + \mathit{hi} ) / 2 \).

When the answer \( h \) is near the start, or the length of the vector is not known, the search of Bentley and Yao doubles a bound before the binary search (gallopSearch() of BinarySearch.h, exponentialSearch() and unboundedSearch() of MonotoneSearch.h): the probes at the places \( 0 , 1 , 3 , 7 , \ldots , 2^k - 1 \) stop at the first \( k = \lceil \log_2 ( h + 1 ) \rceil \) with \( A[ 2^k - 1 ] \ge v \), and a binary search on the last interval but the place \( 2^k - 1 \), already compared, i.e., on \( 2^{k-1} - 1 \) places, costs \( k - 1 \) more (and fewer when the doubling passes the end of the vector); in all, for \( h \ge 1 \),

\[ 2 \lceil \log_2 ( h + 1 ) \rceil \tag{3} \]

comparisons (1 for \( h = 0 \)), which depend on the answer and not on \( n \). Bentley and Yao also show that applying the same idea to the search of \( k \) gives \( \log_2 h + \log_2 \log_2 h + \cdots \), close to the lower bound \( \log_2 h \). The same scheme searches any monotone predicate on the integers, e.g., the integer square root (integerSqrt()).

The search by interpolation of section 12.1 (interpolationSearch() of InterpolationSearch.h) probes the place that a linear model of the keys predicts,

\[ m = \mathit{lo} + \Big\lfloor ( \mathit{hi} - \mathit{lo} ) \frac{v - A[ \mathit{lo} ]}{A[ \mathit{hi} ] - A[ \mathit{lo} ]} \Big\rfloor , \tag{4} \]

instead of the middle one. On keys drawn independently from the uniform distribution the expected number of probes is \( \log_2 \log_2 n + O( 1 ) \) (Perl, Itai and Avni), since the expected error of (4) on a part of length \( \ell \) is of the order of \( \sqrt{\ell} \), so that each probe takes, in expectation, the square root of the length; on keys far from uniform (e.g., growing exponentially) a probe may exclude a single item, and the worst case is \( O( n ) \). The learned index refines the same idea with a model that has a guaranteed error (see Searches laid out for the memory).

Two searches of Knuth trade the division of the middle for additions alone: the Fibonacci search (fibonacciSearch() of KnuthSearches.h) splits a part of length \( F_{k+1} - 1 \) at its \( F_{k-1} \)-th item into parts of lengths \( F_{k-1} - 1 \) and \( F_k - 1 \), at most about \( \log_\phi n \approx 1.44 \log_2 n \) comparisons with \( \phi \) the golden ratio, and the uniform binary search (uniformBinarySearch()) keeps a place and the width of the next step, taken from a table computed once. Finally, the searches of SortedSearches.h apply the invariant (2) to other predicates that are false and then true along the vector: the rotation point of a rotated vector, which is the first place with \( A[ m ] \le A[ n - 1 ] \); the item closest to a value, which is \( A[ r ] \) or \( A[ r - 1 ] \) for \( r = \mathrm{lowerBound}( x ) \); and the item of rank \( k \) of two sorted vectors, where the number \( i \) of the \( k + 1 \) smallest items taken from the shorter vector is the first one with \( S[ i ] \ge L[ k - i ] \).

The searches of a key in a sorted vector
FunctionComparisonsSource
binarySearch()\( 2 ( \lfloor \log_2 n \rfloor + 1 ) \) at mostsection 1.2
lowerBound(), upperBound()\( \lceil \log_2 ( n + 1 ) \rceil \), as (1)exercise 12.13
gallopSearch(), exponentialSearch()\( 2 \lceil \log_2 ( h + 1 ) \rceil + O( 1 ) \), \( h \) the answerBentley and Yao (1976)
interpolationSearch()\( O( \log \log n ) \) expected on uniform keys, \( O( n ) \) in the worst casesection 12.1, Perl, Itai and Avni (1978)
fibonacciSearch()about \( 1.44 \log_2 n \)Ferguson (1960), Knuth
uniformBinarySearch()\( \lfloor \log_2 n \rfloor + 1 \) at mostKnuth

Searches laid out for the memory

On a modern processor the comparisons of a binary search cost less than the two events that surround them: a miss of the cache at each of the first levels, since the places probed are far apart, and a misprediction of the branch that follows each comparison, which on random keys is right half of the times. The headers StaticSearch.h and PGMIndex.h remove the two costs, one at a time.

The binary search with no branch of Khuong and Morin (branchlessLowerBound()) keeps a base \( b \) and a length \( \ell \), and at each step sets \( b \gets b + h \) if \( A[ b + h ] < v \), with \( h = \lfloor \ell / 2 \rfloor \), and \( \ell \gets \ell - h \) whatever the outcome: the comparison feeds a conditional move rather than a jump, and since the next two places that may be probed are known, both are prefetched, so that the misses of two steps overlap. The S+ tree of Slotin (SPlusTree) removes the misses instead: the sorted items, cut into nodes of \( B \) items, are the leaves of a static B+-tree whose inner nodes have \( B \) keys and \( B + 1 \) children, stored level by level with no pointer, and a search reads one line per level, i.e.,

\[ H = 1 + \Big\lceil \log_{B+1} \Big\lceil \frac{n}{B} \Big\rceil \Big\rceil \tag{5} \]

lines, against the \( \log_2 n - \log_2 B \) misses of the binary search; in a node the child to take is the count of the keys smaller than \( v \), which the vectors of the processor compute with no branch (countLess() of CountLess.h).

The PGM-index of Ferragina and Vinciguerra (PGMIndex) replaces the inner nodes by a model of the keys: the points \( ( A[ i ] , i ) \) are covered by the fewest segments whose lines predict each place within \( \epsilon \), and the first keys of the segments are covered in turn, with error \( \epsilon_r \), up to a single segment. The fewest segments are found in one pass by the algorithm of O'Rourke, which keeps the lines that pass between the points moved up and down by \( \epsilon \) as the region between two convex hulls, each point updating them in amortized \( O( 1 ) \). Since a horizontal line through the middle of any \( 2 \epsilon + 1 \) consecutive places is within the error, a segment (but the last) covers keys whose first places span at least \( 2 \epsilon + 1 \) places; hence the last level has \( m \le \lceil n / ( 2 \epsilon + 1 ) \rceil \) segments, there are \( O( \log_{2 \epsilon_r} m ) \) levels, and a search, a binary search of \( O( \epsilon_r ) \) places per level and one of \( O( \epsilon ) \) places at the end, costs

\[ O( \log \epsilon_r \cdot \log_{2 \epsilon_r} m + \log \epsilon ) , \tag{6} \]

in a space proportional to \( m \), which on regular keys is far smaller than \( n / ( 2 \epsilon ) \).

The searches laid out for the memory
StructureLines readSpace besides \( A \)Source
branchlessLowerBound()\( \lceil \log_2 n \rceil + 1 \) probes, misses overlappednoneKhuong and Morin (2017)
SPlusTree\( H \) of (5)\( n / B \) itemsSlotin (2022)
PGMIndex\( O( \log_{2 \epsilon_r} m ) \) windows, \( O( \epsilon / B + 1 ) \) lines at the end28 bytes per segmentFerragina and Vinciguerra (2020)

The minimum and the local optima

Lemma 2 (the minimum). Every comparison-based algorithm that finds the minimum of \( n \) distinct items makes \( n - 1 \) comparisons at least (section 2.6), and min() of Minimum.h makes exactly \( n - 1 \) (section 1.2).

Indeed, an item that has never lost a comparison may still be the minimum, and a comparison makes at most one item lose for the first time; hence \( n - 1 \) comparisons are needed to leave a single item that never lost. The same argument gives the bound of the minimum and the maximum together (minMax()), where an item must lose once to be excluded from being the minimum and win once to be excluded from being the maximum: a comparison of two items never compared gives one loss and one win at once, the others at most one of the two, and pairing the items before comparing them with the current minimum and maximum spends

\[ \Big\lceil \frac{3 n}{2} \Big\rceil - 2 \tag{7} \]

comparisons, which is optimal (Pohl, beyond the book); the divide et impera of minMaxDivide() reaches (7) when \( n \) is a power of 2, by the recurrence \( T( n ) = 2 T( n / 2 ) + 2 \), \( T( 2 ) = 1 \).

A local optimum is cheaper than the minimum. A peak of \( A \) is an item not smaller than its neighbors, the places out of \( A \) counting as \( -\infty \), and one always exists, e.g., the maximum. findPeak() of LocalOptima.h keeps the invariant that \( A[ \mathit{lo} .. \mathit{hi} ] \) rises into \( \mathit{lo} \) and falls out of \( \mathit{hi} \), i.e., \( A[ \mathit{lo} - 1 ] < A[ \mathit{lo} ] \) and \( A[ \mathit{hi} ] \ge A[ \mathit{hi} + 1 ] \): under it the maximum of the part is a peak of \( A \), and comparing \( A[ m ] \) with \( A[ m + 1 ] \) keeps it on one of the two halves. Hence a peak costs \( \lceil \log_2 n \rceil \) comparisons, against the \( n - 1 \) of the maximum. On a binary tree the walk down to a smaller child gives a local minimum in \( O( h ) \), \( h \) the height; on general graphs no such bound exists, since a local minimum of the hypercube of dimension \( d \) needs about \( 2^{d / 2} \) evaluations (Aldous).

The selection

The item of rank \( k \) can be found without sorting. The selection of Hoare (selection() of Selection.h, section 17.1) partitions the part around a pivot as quicksort does, and goes on in the side that holds rank \( k \) only. With the pivot chosen at random its rank is uniform, the side kept is in the worst case the larger one, and the expected number of comparisons satisfies

\[ T( n ) \le n - 1 + \frac{2}{n} \sum_{q = \lfloor n / 2 \rfloor}^{n - 1} T( q ) , \tag{8} \]

whose solution, by substitution of \( T( q ) \le c q \), is \( T( n ) \le c n \) with \( c = 4 \); hence the selection is linear in expectation on every input, while a pivot that is always the smallest item gives \( \Theta( n^2 ) \).

Lemma 3 (the median of the medians). If the pivot is the median of the medians of the groups of 5 items, at least \( 3 n / 10 - O( 1 ) \) items lie on each side of it, and the selection makes

\[ T( n ) \le T( n / 5 ) + T( 7 n / 10 ) + O( n ) = O( n ) \tag{9} \]

comparisons in the worst case (Blum, Floyd, Pratt, Rivest and Tarjan).

Indeed, half of the \( n / 5 \) medians are not larger than the pivot, and each of them has 3 items of its group not larger than it; the same holds on the other side. The pivot costs a selection on \( n / 5 \) items, the remaining part has at most \( 7 n / 10 \) of them, and since \( 1 / 5 + 7 / 10 < 1 \) the work of the levels of the recursion falls geometrically, whence (9) (medianOfMedians()).

The engineered nthElement() of NthElement.h reaches fewer comparisons than (8) by the sampling of Floyd and Rivest: a sample of about \( n^{2/3} \) items, selected recursively, gives a pivot whose rank is just past \( k \) with high probability, so that one partition leaves the part of rank \( k \) with \( o( n ) \) items, and the expected number of comparisons is \( n + \min( k , n - k ) + o( n ) \) (Kiwiel), which is optimal up to the term \( o( n ) \). Each round charges the items of its part to a budget of \( 4 n \) items, and a round whose part the rest of the budget does not cover falls back to the median of the medians, whose rounds cost (9) (on many items equal to the pivot, a second partition takes them away when the part kept would exceed \( 7 m / 10 + 2 \) items of a part of \( m \); the device is the introselect of Musser, with the budget counted in items rather than in rounds); the other rounds partition at most \( 4 n \) items, and their samples, of \( O( m^{2/3} ) \) items for a part of \( m > 600 \), less than \( m / 16 \), are selected within their own budgets, so that by induction the worst case is \( O( n ) \).

The selection of the item of rank \( k \)
FunctionPivotComparisons
selection()at random, or the first item\( O( n ) \) expected by (8), \( \Theta( n^2 ) \) in the worst case
medianOfMedians()the median of the medians of the groups of 5\( O( n ) \) in the worst case, by (9)
nthElement()the sample of Floyd and Rivest, the median of three on short parts\( n + \min( k , n - k ) + o( n ) \) expected, \( O( n ) \) in the worst case

Range minima

After a preprocessing of \( A \), the query \( \mathrm{RMQ}( i , j ) \) is answered without scanning the range. The sparse table (SparseTable of RangeMinimum.h) stores \( \mathrm{RMQ}( i , i + 2^L - 1 ) \) for every \( i \) and \( L \), each from two entries of the row before, in \( O( n \log n ) \); a query takes the better of the two entries of length \( 2^L \), \( L = \lfloor \log_2 ( j - i + 1 ) \rfloor \), that start at \( i \) and end at \( j \), which cover the range, since the minimum does not mind the overlap.

The linear preprocessing rests on a tree. The Cartesian tree of \( A \) has the leftmost minimum of \( A \) as its root, and the Cartesian trees of the parts on its left and on its right as its subtrees (cartesianTree(), which builds it in \( O( n ) \) with a stack holding its right spine, each item pushed and popped once).

Lemma 4 (Bender and Farach-Colton). \( \mathrm{RMQ}( i , j ) \) is the lowest common ancestor of \( i \) and \( j \) in the Cartesian tree of \( A \), i.e., the node of least depth among those that the Euler tour of the tree visits between the first visits of \( i \) and \( j \).

Indeed, the lowest common ancestor \( a \) of \( i \) and \( j \) is the first node whose place falls in \( [ i , j ] \) on the path from the root, so that the range lies in the subtree of \( a \), whose root is its minimum; between the two first visits the tour does not leave that subtree and returns to \( a \), the only node of least depth there. The depths along a tour differ by exactly 1 at each step, and the queries on such an array (PlusMinusOneRangeMinimum) are answered in \( O( 1 ) \) after \( O( n ) \) preprocessing: the array is cut into blocks of \( d = \lfloor \log_2 n \rfloor / 2 \) items, a sparse table on the \( n / d \) minima of the blocks costs \( O( ( n / d ) \log n ) = O( n ) \), and a block is determined, up to an additive constant, by its \( d - 1 \) steps of \( \pm 1 \); hence the answers inside all the possible blocks are built once in a table (the trick of the Four Russians) of

\[ 2^{d - 1} \cdot d^2 \le \sqrt{n} \, \log_2^2 n = o( n ) \tag{10} \]

entries. Thus RangeMinimum answers in \( O( 1 ) \) after \( O( n ) \) preprocessing on any array.

In practice the constant factors of the reduction are large, and WordRangeMinimum.h keeps the decomposition into blocks but answers inside a block of 64 items by the bits of a word: the stack of the minima from the right of the block up to \( j \), as a mask of 64 bits, has as its lowest bit at or above \( i \) the leftmost minimum of \( A[ i .. j ] \), one count of the trailing zeros, and a query makes at most five reads of the memory, independent of one another.

The structures of the range minima
StructurePreprocessingQuerySource
SparseTable\( O( n \log n ) \) time and space\( O( 1 ) \)Bender and Farach-Colton (2000)
PlusMinusOneRangeMinimum\( O( n ) \)\( O( 1 ) \), on steps of \( \pm 1 \)Bender and Farach-Colton (2000)
RangeMinimum\( O( n ) \)\( O( 1 ) \)Bender and Farach-Colton (2000)
WordRangeMinimum\( O( n ) \), about 22 bytes per item of 32 bits\( O( 1 ) \), five reads at mostBaumstark, Gog, Heuer and Labeit (2017)

The PGM-index compressed and dynamic

The segments of the PGM-index (see Searches laid out for the memory) take 28 bytes each, a key, two doubles and a place; the compressed PGM-index of Ferragina and Vinciguerra (CompressedPGMIndex) shares the slopes among the segments and codes the rest in a few tens of bits. The lines that are within \( \epsilon \) of the points of a segment, i.e., the pairs \( ( \alpha , \beta ) \) with \( | \beta + \alpha x_i - y_i | \le \epsilon \) for each of its points, are the intersection of \( 2 k \) half-planes, a convex region, and its shadow on the axis of the slopes is the interval \( [ \alpha^- , \alpha^+ ] \) whose ends are the two extreme lines of the algorithm of O'Rourke; each slope of the interval has an intercept within the error, the middle of \( [ \max_i ( y_i - \alpha x_i ) - \epsilon , \min_i ( y_i - \alpha x_i ) + \epsilon ] \). Hence a set of slopes serves all the segments if it hits each of their intervals.

Lemma 5 (the stabbing of the intervals). Sort the intervals by their left ends, and grow a group while the next interval meets the intersection of the group, opening a new group otherwise; one slope per group, in the intersection, hits all the intervals, and no set of fewer slopes does.

Indeed, every interval of a group contains the intersection of the group, which is not empty by construction. In each group, let \( I_g \) be the interval of least right end, which is the right end of the intersection; the first interval of the next group begins after it, and so do all the later ones, since the left ends increase. The intervals \( I_g \) are then pairwise disjoint, and a slope hits at most one of them: as many slopes as groups are needed.

Each segment then keeps the index of its slope and its intercept, as a distance from its first place of at most \( \epsilon + 1 \); the first places of the segments, increasing, are kept by Elias-Fano (see Compressed vectors and Elias-Fano), and their first keys whole, searched by a PGM-index of their own in place of the levels above: with \( m \) segments and \( \sigma \) slopes,

\[ 64 + 2 + \Big\lceil \log_2 \frac{n}{m} \Big\rceil + \lceil \log_2 \sigma \rceil + \lceil \log_2( 2 \epsilon + 3 ) \rceil \tag{11} \]

bits per segment and \( 32 \sigma \) for the slopes, in single precision. Elias-Fano on the first keys would save \( 62 - \log_2( u / m ) \) bits a segment for keys in a universe of size \( u \), but its rank scans the bucket of the key, and on skewed keys most of the first keys crowd into a few buckets; the PGM-index of the keys finds the segment in the time of the levels of the plain PGM-index, and a search adds to that two selects and a field of bits. The rounding of a shared slope to a float may take a line out of the error; the construction checks each segment and gives its own slope to one whose line misses a point by more than \( \epsilon + 1 \).

The dynamic PGM-index (DynamicPGMIndex) keeps the pairs in a buffer of \( b_0 \) pairs and in sorted levels \( L_1 , L_2 , \ldots \) of capacities \( c_t = b_0 B^t \), each with its PGM-index when it is large enough for the model to pay (as in the implementation of the paper) and with a blocked filter of Bloom of its keys, as the levels of the stores by log-structured merge have (see Dayan, Athanassoulis and Idreos), by the logarithmic method of Bentley and Saxe: a key may be in several levels, the newest pair counts, a removal inserts a tombstone, and when the buffer is full it is merged, with the levels before it, into the first level \( L_t \) that has room for them all.

Lemma 6 (the logarithmic method). An insertion or a removal costs \( O( B \log_B( n / b_0 ) ) \) amortized time, \( n \) the pairs inserted, and a lookup searches \( O( \log_B( n / b_0 ) ) \) levels.

Indeed, \( L_t \) is chosen because the pairs of the buffer and of the levels before \( L_{t-1} \) do not fit in the room left in \( L_{t-1} \), so that with those of \( L_{t-1} \) they are more than \( c_{t-1} = c_t / B \) (more than \( b_0 \) for \( t = 1 \), the buffer being full); the merge and the construction of the PGM-index of the result are linear, \( O( c_t ) \), that is \( O( B ) \) per pair brought into \( L_t \). A pair is brought into a level only from the levels before it, hence into each level at most once, and the levels are \( O( \log_B( n / b_0 ) ) \) since \( c_t \) grows by \( B \). A lookup stops at the newest level that has the key; lowerBound() and the visit of a range merge the levels from the places of the key, and skip the keys whose newest pair is a tombstone. The tombstones are dropped when the merge lands on the last level, where no older pair is left for them to hide. With the filters, a lookup of a key that is not there reads one line of cache per level instead of searching each, and one that is there reads a line per newer level and searches its own; the filter of a level takes the keys that a merge brings in, and is built again only when the keys have doubled, so that the filters add a constant number of insertions into a filter per key and level to the cost of Lemma 6.

References

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, sections 1.2, 2.6, 2.7.1, 2.7.4, 12.1 and 17.1, https://algoritmicamente.it/materiali/libro/capitoli/cap01.pdf, and Esercizi Divide-et-impera, Esercizi Alberi and Esercizi vari, Raccolte da compiti scritti
D. E. Knuth, The Art of Computer Programming, vol. 3, 2nd ed., Addison-Wesley, 1998, section 6.2.1
P. Ferragina, Pearls of Algorithm Engineering, Cambridge University Press, 2023, chapter 10 (Searching Strings by Substring), doi:10.1017/9781009128933
J. L. Bentley, A. C.-C. Yao, An almost optimal algorithm for unbounded searching, Information Processing Letters 5(3), 82-87, 1976, doi:10.1016/0020-0190(76)90071-5
Y. Perl, A. Itai, H. Avni, Interpolation search: a log log N search, Communications of the ACM 21(7), 550-553, 1978, doi:10.1145/359545.359557
D. E. Ferguson, Fibonaccian searching, Communications of the ACM 3(12), 648, 1960, doi:10.1145/367487.367496
P.-V. Khuong, P. Morin, Array layouts for comparison-based searching, ACM Journal of Experimental Algorithmics 22, 1.3:1-1.3:39, 2017, doi:10.1145/3053370
P. Ferragina, G. Vinciguerra, The PGM-index: a fully-dynamic compressed learned index with provable worst-case bounds, Proceedings of the VLDB Endowment 13(8), 1162-1175, 2020, doi:10.14778/3389133.3389135
J. O'Rourke, An on-line algorithm for fitting straight lines between data ranges, Communications of the ACM 24(9), 574-578, 1981, doi:10.1145/358746.358758
D. Aldous, Minimization algorithms and random walk on the d-cube, The Annals of Probability 11(2), 403-413, 1983, doi:10.1214/aop/1176993605
I. Pohl, A sorting problem and its complexity, Communications of the ACM 15(6), 462-464, 1972, doi:10.1145/361405.361423
C. A. R. Hoare, Algorithm 65: Find, Communications of the ACM 4(7), 321-322, 1961, doi:10.1145/366622.366647
M. Blum, R. W. Floyd, V. Pratt, R. L. Rivest, R. E. Tarjan, Time bounds for selection, Journal of Computer and System Sciences 7(4), 448-461, 1973, doi:10.1016/S0022-0000(73)80033-9
R. W. Floyd, R. L. Rivest, Expected time bounds for selection, Communications of the ACM 18(3), 165-172, 1975, doi:10.1145/360680.360691
K. C. Kiwiel, On Floyd and Rivest's SELECT algorithm, Theoretical Computer Science 347(1-2), 214-238, 2005, doi:10.1016/j.tcs.2005.06.032
M. A. Bender, M. Farach-Colton, The LCA problem revisited, Proceedings of LATIN 2000, LNCS 1776, 88-94, 2000, doi:10.1007/10719839_9
J. Fischer, V. Heun, Space-efficient preprocessing schemes for range minimum queries on static arrays, SIAM Journal on Computing 40(2), 465-492, 2011, doi:10.1137/090779759
N. Baumstark, S. Gog, T. Heuer, J. Labeit, Practical range minimum queries revisited, Proceedings of SEA 2017, LIPIcs 75, 12:1-12:16, 2017, doi:10.4230/LIPIcs.SEA.2017.12
J. L. Bentley, J. B. Saxe, Decomposable searching problems I: static-to-dynamic transformation, Journal of Algorithms 1(4), 301-358, 1980, doi:10.1016/0196-6774(80)90015-2
N. Dayan, M. Athanassoulis, S. Idreos, Monkey: optimal navigable key-value store, Proceedings of SIGMOD 2017, 79-94, 2017, doi:10.1145/3035918.3064054