Eg. RMQ(4,7) = 6
1D RMQ
One of the classical data structure problems with lots of
applications.
Has been studied extensively.
Linear-space data structures have been designed that
achieve constant query-time by
[Harel and Tarjan, 84]
[Schieber and Vishkin, 88]
[Berkman et al., 89]
[Bender and Farach-Colton, 00]
[Alstrup et al., 02]
1D RMQ
All these data structures take linear space O(n log n)
bits.
[Sadakane, 03] improved the space to 4n+o(n) bits.
[Fischer, 10] further improved it to 2n+o(n) bits.
Most of these structures are based on Cartesian tree.
Cartesian tree
Models
Encoding model
Indexing model
Upper
bound
Lower
bound
Encoding
model
Index
model
Encoding
model
Upper
bound
Lower
bound
Index
model
Query
time
Model
No data structure
O(N)
Indexing
Tabulate answers
O(N 2 log N)
O(1)
Encoding
Store permutation
O(N log N)
O(N)
Encoding
Solution
Minimum
-14
10
15
15
10
12
13
11
-4
-5
-1
21
14
20
-17
32
13
16
input matrix
rank matrix
Upper
bound
Lower
bound
Index
model
Encoding
model
Index
model
Define a set of
matrices where the RMQ
answers differ for all
the matrices
Bits required is at least
log
= (N log
m)
2D
Upper
bound
Lower
bound
Encoding
model
Index
model
Fischer (2010)
2D RMQ
?
?
Effective Entropy
information content of the data structure
Given a set of objects S,
a set of queries Q,
let C be the set of equivalence classes of S
induced by Q (x, y S are equivalent iff they
cannot be distinguished by queries in Q).
We want to store x in ceiling{lg |C|} bits.
2D RMQ
Effective entropy for the 2D RMQ problem:
2D RMQ
Special cases
Results
Random input matrix:
Small values of m:
Lower bound for m = 3: 8n O(lg n)
[ Random array:
(1.736..)n ]
2D RMQ for m = 2
Simple solution [Brodal et al. 2010]:
T
B
2D RMQ encoding
For m = 2:
We can also show a lower bound of 5n - O(lg n) bits
any n-bit sequence can be used to merge two CTs.
We can answer 2D RMQ queries in (5+)n bits and
O(1/) query time, for any > 0.
For m = 3:
Lower bound: 8n O(lg n)
Upper bound: 8.32n
Data structure?
prefix-top-3-positions(5) = {1, 3, 5}
prefix-top-3-values(5) = {2, 7, 8}
prefix-3rd-position(5) = 5
prefix-3rd-value(5) = 8
Conclusions
Various time-space trade-offs for the RMQ
problem in the indexing and encoding models.
Encodings for specific (small) values of the
parameter.
Encodings for random inputs.
Top-k encodings
Prefix queries: almost tight bounds.
2-sided queries: some trade-offs.
Open problems
2D RMQ:
Closing the gap between the upper and lower
bounds in the indexing model for 2D RMQ.
Improving the bounds for small m.
Higher dimensions.
Top-k encodings:
Better bounds (and data structures ?) for the
2-sided kth-smallest queries.