Misplaced Pages

Predecessor problem

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
(Redirected from Dynamic predecessor problem) Query of largest element in a set less than an element

In computer science, the predecessor problem involves maintaining a set of items to, given an element, efficiently query which element precedes or succeeds that element in an order. Data structures used to solve the problem include balanced binary search trees, van Emde Boas trees, and fusion trees. In the static predecessor problem, the set of elements does not change, but in the dynamic predecessor problem, insertions into and deletions from the set are allowed.

The predecessor problem is a simple case of the nearest neighbor problem, and data structures that solve it have applications in problems like integer sorting.

Definition

The problem consists of maintaining a set S, which contains a subset of U integers. Each of these integers can be stored with a word size of w, implying that U 2 w {\displaystyle U\leq 2^{w}} . Data structures that solve the problem support these operations:

  • predecessor(x), which returns the largest element in S strictly smaller than x
  • successor(x), which returns the smallest element in S strictly greater than x

In addition, data structures which solve the dynamic version of the problem also support these operations:

  • insert(x), which adds x to the set S
  • delete(x), which removes x from the set S

The problem is typically analyzed in a transdichotomous model of computation such as word RAM.

Data structures

A binary tree with 4 levels. The nodes on each level are: 3: (), 2: (0) and (1), 1: (00) and (10), 0: (001), (100) and (101). The unlabeled node is the root. There are directed edges between the following nodes: ()->(0), ()->(1), (0)->(00), (0)->(001) in blue, (1)->(10), (1)->(101) in blue, (00)->(001) twice, once in blue, (10)->(100), (10)->(101), (001)<->(100), (100)<->(101). The nodes on each level are contained in a box, labeled with LSS(<level>).
An x-fast trie containing the integers 1 (0012), 4 (1002) and 5 (1012), which can be used to efficiently solve the predecessor problem.

One simple solution to this problem is to use a balanced binary search tree, which achieves (in Big O notation) a running time of O ( log n ) {\displaystyle O(\log n)} for predecessor queries. The Van Emde Boas tree achieves a query time of O ( log log U ) {\displaystyle O(\log \log U)} , but requires O ( U ) {\displaystyle O(U)} space. Dan Willard proposed an improvement on this space usage with the x-fast trie, which requires O ( n log U ) {\displaystyle O(n\log U)} space and the same query time, and the more complicated y-fast trie, which only requires O ( n ) {\displaystyle O(n)} space. Fusion trees, introduced by Michael Fredman and Willard, achieve O ( log w n ) {\displaystyle O(\log _{w}n)} query time and O ( n ) {\displaystyle O(n)} for predecessor queries for the static problem. The dynamic problem has been solved using exponential trees with O ( log w n + log log n ) {\displaystyle O(\log _{w}n+\log \log n)} query time, and with expected time O ( log w n ) {\displaystyle O(\log _{w}n)} using hashing.

Mathematical properties

There have been a number of papers proving lower bounds on the predecessor problem, or identifying what the running time of asymptotically optimal solutions would be. For example, Michael Beame and Faith Ellen proved that for all values of w, there exists a value of n with query time (in Big Theta notation) Ω ( log w log log w ) {\displaystyle \Omega \left({\tfrac {\log w}{\log \log w}}\right)} , and similarly, for all values of n, there exists a value of n such that the query time is Ω ( log n log log n ) {\displaystyle \Omega \left({\sqrt {\tfrac {\log n}{\log \log n}}}\right)} . Other proofs of lower bounds include the notion of communication complexity.

For the static predecessor problem, Mihai Pătrașcu and Mikkel Thorup showed the following lower bound for the optimal search time, in the cell-probe model: O ( 1 ) min { log w n lg lg n a lg a lg ( a lg n lg a ) lg a lg ( lg a / lg lg n a ) {\displaystyle O(1)\min \left\{{\begin{array}{l}\log _{w}n\\\lg {\frac {\ell -\lg n}{a}}\\{\frac {\lg {\frac {\ell }{a}}}{\lg \left({\frac {a}{\lg n}}\,\cdot \,\lg {\frac {\ell }{a}}\right)}}\\{\frac {\lg {\frac {\ell }{a}}}{\lg \left(\lg {\frac {\ell }{a}}\right/\left.\lg {\frac {\lg n}{a}}\right)}}\end{array}}\right.} where the RAM has word length w {\displaystyle w} , the set contains n {\displaystyle n} integers of {\displaystyle \ell } bits each and is represented in the RAM using S {\displaystyle S} words of space, and defining a = lg S n + lg w {\displaystyle a=\lg {\frac {S}{n}}+\lg w} .

In the case where w = = γ lg n {\displaystyle w=\ell =\gamma \lg n} for γ > 1 {\displaystyle \gamma >1} and S = n lg O ( 1 ) n {\displaystyle S=n\cdot \lg ^{O(1)}n} , the optimal search time is Θ ( lg ) {\displaystyle \Theta (\lg \ell )} and the van Emde Boas tree achieves this bound.

See also

References

  1. ^ Beame, Paul; Fich, Faith (August 2002). "Optimal Bounds for the Predecessor Problem and Related Problems". Journal of Computer and System Sciences. 65 (1): 38–72. doi:10.1006/jcss.2002.1822. S2CID 1991980.
  2. Rahman, Naila; Cole, Richard; Raman, Rajeev (17 August 2001). Optimized Predecessor Data Structures for Internal Memory (PDF). International Workshop on Algorithm Engineering. pp. 67–78.
  3. Willard, Dan (24 August 1983). "Log-logarithmic worst-case range queries are possible in space Θ(n)". Information Processing Letters. 17 (2): 81–84. doi:10.1016/0020-0190(83)90075-3.
  4. Fredman, Michael; Willard, Dan (1990). "Blasting through the information theoretic barrier with fusion trees". Symposium on Theory of Computing: 1–7.
  5. Andersson, Arne; Thorup, Mikkel (2007), "Dynamic ordered sets with exponential search trees", Journal of the ACM, 54 (3): A13, arXiv:cs/0210006, doi:10.1145/1236457.1236460, MR 2314255, S2CID 8175703.
  6. Raman, Rajeev (1996), "Priority queues: small, monotone and trans-dichotomous", Fourth Annual European Symposium on Algorithms (ESA '96), Barcelona, Spain, September 25–27, 1996, Lecture Notes in Computer Science, vol. 1136, Berlin: Springer-Verlag, pp. 121–137, doi:10.1007/3-540-61680-2_51, ISBN 978-3-540-61680-1, MR 1469229.
  7. ^ Pătraşcu, Mihai; Thorup, Mikkel (21 May 2006). "Time-space trade-offs for predecessor search". Proceedings of the thirty-eighth annual ACM symposium on Theory of Computing. pp. 232–240. arXiv:cs/0603043. doi:10.1145/1132516.1132551. ISBN 1595931341. S2CID 1232.
Categories: