In
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied 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 , which contains a subset of integers. Each of these
integers can be stored with a
word size of , implying that
. Data structures that solve the problem support these operations:
*
predecessor(x)
, which returns the largest element in strictly smaller than
*
successor(x)
, which returns the smallest element in strictly greater than
In addition, data structures which solve the
dynamic version of the problem also support these operations:
*
insert(x)
, which adds to the set
*
delete(x)
, which removes from the set
The problem is typically analyzed in a
transdichotomous model of computation such as
word RAM.
Data structures

One simple solution to this problem is to use a
balanced binary search tree, which achieves (in
Big O notation) a
running time of
for predecessor queries. The
Van Emde Boas tree achieves a query time of
, but requires
space
Space is a three-dimensional continuum containing positions and directions. In classical physics, physical space is often conceived in three linear dimensions. Modern physicists usually consider it, with time, to be part of a boundless ...
.
Dan Willard proposed an improvement on this space usage with the
x-fast trie, which requires
space and the same query time, and the more complicated
y-fast trie, which only requires
space.
Fusion trees, introduced by
Michael Fredman and Willard, achieve
query time and
for predecessor queries for the static problem.
The dynamic problem has been solved using
exponential trees with
query time, and with
expected time 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 ,
there exists a value of with query time (in
Big Theta notation)
, and similarly, for all values of , there exists a value of such that the query time is
.
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:
where the RAM has word length
, the set contains
integers of
bits each and is represented in the RAM using
words of space, and defining
.
In the case where
for
and
, the optimal search time is
and the
van Emde Boas tree achieves this bound.
[
]
See also
* Integer sorting
* y-fast trie
* Fusion tree
References
{{reflist
Data structures
Computational problems