Interleave lower bound
In the theory of optimal binary search trees, the interleave lower bound is a lower bound on the number of operations required by a Binary Search Tree (BST) to execute a given sequence of accesses. Several variants of this lower bound have been proven.[1][2][3] This article is based on a variation of the first Wilber's bound.[4] This lower bound is used in the design and analysis of Tango tree.[4] Furthermore, this lower bound can be rephrased and proven geometrically, Geometry of binary search trees.[5]
Definition
The bound is based on a fixed perfect BST [math]\displaystyle{ P }[/math], called the lower bound tree, over the keys [math]\displaystyle{ \{1, 2,..., n \} }[/math]. For example, for [math]\displaystyle{ n = 7 }[/math], [math]\displaystyle{ P }[/math] can be represented by the following parenthesis structure:
- [([1] 2 [3]) 4 ([5] 6 [7])]
For each node [math]\displaystyle{ y }[/math] in [math]\displaystyle{ P }[/math], define:
- [math]\displaystyle{ Left(y) }[/math] to be the set of nodes in the left sub-tree of [math]\displaystyle{ y }[/math], including [math]\displaystyle{ y }[/math].
- [math]\displaystyle{ Right(y) }[/math] to be the set of nodes in the right sub-tree of [math]\displaystyle{ y }[/math].
Consider the following access sequence: [math]\displaystyle{ X = x_1, x_2, ..., x_m }[/math]. For a fixed node [math]\displaystyle{ y }[/math], and for each access [math]\displaystyle{ x_i }[/math], define the label of [math]\displaystyle{ x_i }[/math] with respect to [math]\displaystyle{ y }[/math] as:
- "L" - if [math]\displaystyle{ x_i }[/math] is in [math]\displaystyle{ Left(y) }[/math].
- "R" - if [math]\displaystyle{ x_i }[/math] is in [math]\displaystyle{ Right(y) }[/math];
- Null - otherwise.
The label of [math]\displaystyle{ y }[/math] is the concatenation of the labels from all the accesses. For example, if the sequence of accesses is: [math]\displaystyle{ 7,6,3 }[/math] then the label of the root [math]\displaystyle{ (4) }[/math] is: "RRL", the label of 6 is: "RL", and the label of 2 is: "L".
For every node [math]\displaystyle{ y }[/math], define the amount of interleaving through y as the number of alternations between L and R in the label of [math]\displaystyle{ y }[/math]. In the above example, the interleaving through [math]\displaystyle{ 4 }[/math] and [math]\displaystyle{ 6 }[/math] is [math]\displaystyle{ 1 }[/math] and the interleaving through all other nodes is [math]\displaystyle{ 0 }[/math].
The interleave bound, [math]\displaystyle{ \mathit{IB}(X) }[/math], is the sum of the interleaving through all the nodes of the tree. The interleave bound of the above sequence is [math]\displaystyle{ 2 }[/math].
The Lower Bound Statement and its Proof
The interleave bound is summarized by the following theorem.
Theorem — Let [math]\displaystyle{ X }[/math] be an access sequence. Denote by [math]\displaystyle{ IB(X) }[/math] the interleave bound of [math]\displaystyle{ X }[/math], then [math]\displaystyle{ \mathit{IB}(X)/2 - n }[/math] is a lower bound of [math]\displaystyle{ OPT(X) }[/math], the cost of optimal offline BST that serves [math]\displaystyle{ X }[/math].
The following proof is based on.[4]
Proof
Let [math]\displaystyle{ X = x_1,x_2,...,x_m }[/math] be an access sequence. Denote by [math]\displaystyle{ T_i }[/math] the state of an arbitrary BST at time [math]\displaystyle{ i }[/math] i.e. after executing the sequence [math]\displaystyle{ x_1,x_2,...,x_i }[/math]. We also fix a lower bound BST [math]\displaystyle{ P }[/math].
For a node [math]\displaystyle{ y }[/math] in [math]\displaystyle{ P }[/math], define the transition point for [math]\displaystyle{ y }[/math] at time [math]\displaystyle{ i }[/math] to be the minimum-depth node [math]\displaystyle{ z }[/math] in the BST [math]\displaystyle{ T_i }[/math] such that the path from the root of [math]\displaystyle{ T_i }[/math] to [math]\displaystyle{ z }[/math] includes both a node from Left(y) and a node from Right(y). Intuitively, any BST algorithm on [math]\displaystyle{ T_i }[/math] that accesses an element from Right(y) and then an element from Left(y) (or vice versa) must touch the transition point of [math]\displaystyle{ y }[/math] at least once. In the following Lemma, we will show that transition point is well-defined.
Lemma 1 — The transition point of a node [math]\displaystyle{ y }[/math] in [math]\displaystyle{ P }[/math] at a time [math]\displaystyle{ i }[/math] exists and it is unique.[4]
Define [math]\displaystyle{ \ell }[/math] to be the lowest common ancestor of all nodes in [math]\displaystyle{ T_i }[/math] that are in Left(y). Given any two nodes [math]\displaystyle{ a \lt b }[/math] in [math]\displaystyle{ T_i }[/math], the lowest common ancestor of [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math], denoted by [math]\displaystyle{ lca(a, b) }[/math], satisfies the following inequalities. [math]\displaystyle{ a \leq lca(a, b) \leq b }[/math]. Consequently, [math]\displaystyle{ \ell }[/math] is in Left(y), and [math]\displaystyle{ \ell }[/math] is the unique node of minimum depth in [math]\displaystyle{ T_i }[/math]. Same reasoning can be applied for [math]\displaystyle{ r }[/math], the lowest common ancestor of all nodes in [math]\displaystyle{ T_i }[/math] that are in Right(y). In addition, the lowest common ancestor for all the points in Left(y) and right(y) is also in one of these sets. Therefore, the unique minimum depth node must be among the nodes of Left(y) and right(y). More precisely, it is either [math]\displaystyle{ \ell }[/math] or [math]\displaystyle{ r }[/math]. Suppose, it is [math]\displaystyle{ \ell }[/math]. Then, [math]\displaystyle{ \ell }[/math] is an ancestor of [math]\displaystyle{ r }[/math]. Consequently, [math]\displaystyle{ r }[/math] is a transition points since the path from the root to [math]\displaystyle{ r }[/math] contains [math]\displaystyle{ \ell }[/math]. Moreover, any path in [math]\displaystyle{ T_i }[/math] from the root to a node in the sub-tree of [math]\displaystyle{ y }[/math] must visit [math]\displaystyle{ \ell }[/math] because it is the ancestor of all such nodes, and for any path to a node in the right region must visit [math]\displaystyle{ r }[/math] because it is lowest common ancestor of all the nodes in right(y). To conclude, [math]\displaystyle{ r }[/math] is the unique transition point for [math]\displaystyle{ y }[/math] in [math]\displaystyle{ T_i }[/math].
The second lemma that we need to prove states that the transition point is stable. It will not change until it is touched.
Lemma 2 — Given a node [math]\displaystyle{ y }[/math]. Suppose [math]\displaystyle{ z }[/math] is the transition point of [math]\displaystyle{ y }[/math] at a time [math]\displaystyle{ j }[/math]. If an access algorithm for a BST does not touch [math]\displaystyle{ z }[/math] in [math]\displaystyle{ T_i }[/math] for [math]\displaystyle{ i \in [j, k] }[/math], then the transition point of [math]\displaystyle{ y }[/math] will remain [math]\displaystyle{ z }[/math] in [math]\displaystyle{ T_i }[/math] for [math]\displaystyle{ i \in [j, k] }[/math]. [4]
Consider the same definition for [math]\displaystyle{ \ell }[/math] and [math]\displaystyle{ r }[/math] as in Lemma 1. Without loss of generality, suppose also that [math]\displaystyle{ \ell }[/math] is an ancestor of [math]\displaystyle{ r }[/math] in the BST at time [math]\displaystyle{ j }[/math], denoted by [math]\displaystyle{ T_j }[/math]. As a result, [math]\displaystyle{ r }[/math] will be the transition point of [math]\displaystyle{ y }[/math]. By hypothesis, the BST algorithm does not touch the transition point, in our case [math]\displaystyle{ r }[/math], for the entirety of [math]\displaystyle{ [j, k] }[/math]. Therefore, it does not touch any node in Right(y). Consequently, [math]\displaystyle{ r }[/math] remains the lowest common ancestor for any two nodes in Right(y). However, the access algorithm might touch a node in Left(y). More precisely, it might touch the lowest common ancestor of all nodes in Left(y) at a time [math]\displaystyle{ i }[/math], which we will denoted by [math]\displaystyle{ \ell_i }[/math]. Even so, [math]\displaystyle{ \ell_i }[/math] will remain the ancestor of [math]\displaystyle{ r }[/math] for the following reasons: Firstly, observe that any node of Left(y) that was outside the tree rooted at [math]\displaystyle{ r }[/math] at time [math]\displaystyle{ j }[/math] cannot enter this tree at a time [math]\displaystyle{ i \in [j, k] }[/math], since [math]\displaystyle{ r }[/math] isn't touched in this time frame. Secondly, there exists at least one node [math]\displaystyle{ \ell_i' }[/math] in Left(y) outside the tree rooted at [math]\displaystyle{ r }[/math], for any time [math]\displaystyle{ i \in [j, k] }[/math]. This is since [math]\displaystyle{ \ell }[/math] was initially outside [math]\displaystyle{ r }[/math]'s sub-tree, and no nodes from outside the tree can enter it in this timeframe. Now, consider [math]\displaystyle{ a_i = lca(\ell_i', r) }[/math]. [math]\displaystyle{ a_i }[/math] cannot be [math]\displaystyle{ r }[/math] since [math]\displaystyle{ \ell_i' }[/math] is not in the sub-tree of [math]\displaystyle{ r }[/math]. So, [math]\displaystyle{ a_i }[/math] must be in Left(y), since [math]\displaystyle{ \ell_i' \leq a_i \leq r }[/math]. Consequently [math]\displaystyle{ \ell_i }[/math] must be an ancestor of [math]\displaystyle{ a_i }[/math] and by consequence an ancestor of [math]\displaystyle{ r }[/math] at time [math]\displaystyle{ i }[/math]. Therefore, there always exists a node in Left(y) on the path from the root to [math]\displaystyle{ r }[/math], and as such [math]\displaystyle{ r }[/math] remains the transition point.
The last Lemma toward the proof states that every node [math]\displaystyle{ y \in P }[/math] has its unique transition point.
Lemma 3 — Given a BST at time [math]\displaystyle{ i }[/math], [math]\displaystyle{ T_i }[/math], any node [math]\displaystyle{ y }[/math] in [math]\displaystyle{ T_i }[/math] can be only a transition for at most one node in [math]\displaystyle{ P }[/math].[4]
Given two distinct nodes [math]\displaystyle{ y_1, y_2 \in P }[/math]. Let [math]\displaystyle{ r_1, \ell_1, r_2, \ell_2 }[/math] be the lowest common ancestor of [math]\displaystyle{ Right(y_1), Left(y_1), Right(y_2), Left(y_2) }[/math] respectively. From Lemma 1, we know that the transition point of [math]\displaystyle{ y_i }[/math] is either [math]\displaystyle{ \ell_i }[/math] or [math]\displaystyle{ r_i }[/math] for [math]\displaystyle{ i \in \{1, 2\} }[/math]. Now we have two main cases to consider.
Case 1: There is no ancestrally relation between [math]\displaystyle{ y_1 }[/math] and [math]\displaystyle{ y_2 }[/math] in [math]\displaystyle{ P }[/math]. Consequently, the [math]\displaystyle{ Left(y_1), Left(y_2), Right(y_1), }[/math] and [math]\displaystyle{ Right(y_2) }[/math] are all disjoint. Thus, [math]\displaystyle{ r_1 \neq r_2 \neq \ell_1 \neq \ell_2 }[/math], and the transition points are different.
Case 2: Suppose without loss of generality that [math]\displaystyle{ y_1 }[/math] is an ancestor of [math]\displaystyle{ y_2 }[/math] in [math]\displaystyle{ P }[/math].
Case 2.1: Suppose that the transition point of [math]\displaystyle{ y_1 }[/math] is not in the tree rooted at [math]\displaystyle{ y_2 }[/math] in [math]\displaystyle{ P }[/math]. Thus, it is different from [math]\displaystyle{ \ell_2 }[/math] and [math]\displaystyle{ r_2 }[/math], and consequently the transition point of [math]\displaystyle{ y_2 }[/math].
Case 2.2: The transition point of [math]\displaystyle{ y_1 }[/math] is in the tree rooted at [math]\displaystyle{ y_2 }[/math] in [math]\displaystyle{ P }[/math]. More precisely, it is one of the lowest common ancestor of [math]\displaystyle{ Left(y_2) }[/math] and [math]\displaystyle{ right(y_2) }[/math]. In other words, it is either [math]\displaystyle{ \ell_2 }[/math] or [math]\displaystyle{ r_2 }[/math].
Suppose [math]\displaystyle{ a_1 }[/math] is the lowest common ancestor of the sub-tree rooted at [math]\displaystyle{ y_1 }[/math] and does not contain [math]\displaystyle{ y_2 }[/math]. We have [math]\displaystyle{ \ell_2 }[/math] and [math]\displaystyle{ r_2 }[/math] deeper than [math]\displaystyle{ a_1 }[/math] because one of them is the transition point. Suppose that [math]\displaystyle{ \ell_2 }[/math] is the transition point. Then, [math]\displaystyle{ \ell_2 }[/math] is less deep that [math]\displaystyle{ r_2 }[/math]. In this case, [math]\displaystyle{ \ell_2 }[/math] is the transition point of [math]\displaystyle{ y_1 }[/math] and [math]\displaystyle{ r_2 }[/math] is the transition point of [math]\displaystyle{ y_2 }[/math]. Similar reasoning applies if [math]\displaystyle{ r_2 }[/math] is less deep that [math]\displaystyle{ \ell_2 }[/math]. In sum, the transition point of [math]\displaystyle{ y_1 }[/math] is the less deep from [math]\displaystyle{ \ell_2 }[/math] and [math]\displaystyle{ r_2 }[/math], and [math]\displaystyle{ y_2 }[/math] has the deeper one as a transition point.
In conclusion, the transition points are different in all the cases.
Now, we are ready to prove the theorem. First of all, observe that the number of touched transition points by the offline BST algorithm is a lower bound on its cost, we are counting less nodes than the required for the total cost.
We know by Lemma 3 that at any time [math]\displaystyle{ i }[/math], any node [math]\displaystyle{ y }[/math] in [math]\displaystyle{ T_i }[/math] can be only a transition for at most one node in [math]\displaystyle{ P }[/math]. Thus, It is enough to count the number of touches of a transition node of [math]\displaystyle{ y }[/math], the sum over all [math]\displaystyle{ y }[/math].
Therefore, for a fixed node [math]\displaystyle{ y \in P }[/math], let [math]\displaystyle{ \ell }[/math] and [math]\displaystyle{ r }[/math] to be defined as in Lemma 1. The transition point of [math]\displaystyle{ y }[/math] is among these two nodes. In fact, it is the deeper one. Let [math]\displaystyle{ x_{i_{1}}, x_{i_{2}}, ..., x_{i_p} }[/math] be a maximal ordered access sequence to nodes that alternate between [math]\displaystyle{ Left(y) }[/math] and [math]\displaystyle{ Right(y) }[/math]. Then [math]\displaystyle{ p }[/math] is the amount of interleaving through the node [math]\displaystyle{ y }[/math]. Suppose that the even indexed accesses are in the [math]\displaystyle{ Left(y) }[/math], and the odd ones are in [math]\displaystyle{ Right(y) }[/math] i.e. [math]\displaystyle{ x_{i_{2j}} \in Left(y) }[/math] and [math]\displaystyle{ x_{i_{2j - 1}} \in Right(y) }[/math]. We know by the properties of lowest common ancestor that an access to a node in [math]\displaystyle{ Left(y) }[/math], it must touch [math]\displaystyle{ \ell }[/math]. Similarly, an access to a node in [math]\displaystyle{ Right(y) }[/math] must touch [math]\displaystyle{ r }[/math]. Consider every [math]\displaystyle{ j \in [1, \lfloor p/2 \rfloor] }[/math]. For two consecutive accesses [math]\displaystyle{ x_{i_{2j - 1}} }[/math] and [math]\displaystyle{ x_{i_{2j}} }[/math], if they avoid touching the access point of [math]\displaystyle{ y }[/math], then [math]\displaystyle{ \ell }[/math] and [math]\displaystyle{ r }[/math] must change in between. However, by Lemma 2, such change requires touching the transition point. Consequently, the BST access algorithm touches the transition point of [math]\displaystyle{ y }[/math] at least once in the interval of [math]\displaystyle{ [i_{2j - 1}, i_{2j}] }[/math]. Summing over all [math]\displaystyle{ j \in [1, \lfloor p/2 \rfloor ] }[/math], the best algorithm touches the transition point of [math]\displaystyle{ y }[/math] at least [math]\displaystyle{ \lfloor p/2 \rfloor \geq p/2 - 1 }[/math]. Summing over all [math]\displaystyle{ y }[/math],
[math]\displaystyle{ \sum_{y \in P} p_y/2 - 1 \geq IB(X)/2 - n }[/math]
where [math]\displaystyle{ p_y }[/math] is the amount of interleave through [math]\displaystyle{ y }[/math]. By definition, the [math]\displaystyle{ p_y }[/math]'s add up to [math]\displaystyle{ IB(X) }[/math]. That concludes the proof.
See also
References
- ↑ Wilber, R. (1989). "Lower Bounds for Accessing Binary Search Trees with Rotations". SIAM Journal on Computing 18: 56–67. doi:10.1137/0218004.
- ↑ Hampapuram, H.; Fredman, M. L. (1998). "Optimal Biweighted Binary Trees and the Complexity of Maintaining Partial Sums". SIAM Journal on Computing 28: 1–9. doi:10.1137/S0097539795291598.
- ↑ Patrascu, M.; Demaine, E. D. (2006). "Logarithmic Lower Bounds in the Cell-Probe Model". SIAM Journal on Computing 35 (4): 932. doi:10.1137/S0097539705447256. http://erikdemaine.org/papers/DynamicConnectivity_SICOMP/paper.pdf.
- ↑ 4.0 4.1 4.2 4.3 4.4 4.5 Demaine, E. D.; Harmon, D.; Iacono, J.; Pătraşcu, M. (2007). "Dynamic Optimality—Almost". SIAM Journal on Computing 37: 240–251. doi:10.1137/S0097539705447347. http://erikdemaine.org/papers/Tango_SICOMP/paper.pdf.
- ↑ "The geometry of binary search trees", In Proceedings of the 20th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2009) (New York): 496–505, 2009, doi:10.1137/1.9781611973068.55, ISBN 978-0-89871-680-1, http://erikdemaine.org/papers/BST_SODA2009/
Original source: https://en.wikipedia.org/wiki/Interleave lower bound.
Read more |