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 P {\displaystyle P} , called the lower bound tree, over the keys { 1 , 2 , . . . , n } {\displaystyle \{1,2,...,n\}} . For example, for n = 7 {\displaystyle n=7} , P {\displaystyle P} can be represented by the following parenthesis structure:

[([1] 2 [3]) 4 ([5] 6 [7])]

For each node y {\displaystyle y} in P {\displaystyle P} , define:

  • L e f t ( y ) {\displaystyle Left(y)} to be the set of nodes in the left sub-tree of y {\displaystyle y} , including y {\displaystyle y} .
  • R i g h t ( y ) {\displaystyle Right(y)} to be the set of nodes in the right sub-tree of y {\displaystyle y} .

Consider the following access sequence: X = x 1 , x 2 , . . . , x m {\displaystyle X=x_{1},x_{2},...,x_{m}} . For a fixed node y {\displaystyle y} , and for each access x i {\displaystyle x_{i}} , define the label of x i {\displaystyle x_{i}} with respect to y {\displaystyle y} as:

  • "L" - if x i {\displaystyle x_{i}} is in L e f t ( y ) {\displaystyle Left(y)} .
  • "R" - if x i {\displaystyle x_{i}} is in R i g h t ( y ) {\displaystyle Right(y)} ;
  • Null - otherwise.

The label of y {\displaystyle y} is the concatenation of the labels from all the accesses. For example, if the sequence of accesses is: 7 , 6 , 3 {\displaystyle 7,6,3} then the label of the root ( 4 ) {\displaystyle (4)} is: "RRL", the label of 6 is: "RL", and the label of 2 is: "L".

For every node y {\displaystyle y} , define the amount of interleaving through y as the number of alternations between L and R in the label of y {\displaystyle y} . In the above example, the interleaving through 4 {\displaystyle 4} and 6 {\displaystyle 6} is 1 {\displaystyle 1} and the interleaving through all other nodes is 0 {\displaystyle 0} .

The interleave bound, I B ( X ) {\displaystyle {\mathit {IB}}(X)} , is the sum of the interleaving through all the nodes of the tree. The interleave bound of the above sequence is 2 {\displaystyle 2} .

The Lower Bound Statement and its Proof

The interleave bound is summarized by the following theorem.

Theorem —  Let X {\displaystyle X} be an access sequence. Denote by I B ( X ) {\displaystyle IB(X)} the interleave bound of X {\displaystyle X} , then I B ( X ) / 2 n {\displaystyle {\mathit {IB}}(X)/2-n} is a lower bound of O P T ( X ) {\displaystyle OPT(X)} , the cost of optimal offline BST that serves X {\displaystyle X} .

The following proof is based on.[4]

Proof

Let X = x 1 , x 2 , . . . , x m {\displaystyle X=x_{1},x_{2},...,x_{m}} be an access sequence. Denote by T i {\displaystyle T_{i}} the state of an arbitrary BST at time i {\displaystyle i} i.e. after executing the sequence x 1 , x 2 , . . . , x i {\displaystyle x_{1},x_{2},...,x_{i}} . We also fix a lower bound BST P {\displaystyle P} .

For a node y {\displaystyle y} in P {\displaystyle P} , define the transition point for y {\displaystyle y} at time i {\displaystyle i} to be the minimum-depth node z {\displaystyle z} in the BST T i {\displaystyle T_{i}} such that the path from the root of T i {\displaystyle T_{i}} to z {\displaystyle z} includes both a node from Left(y) and a node from Right(y). Intuitively, any BST algorithm on T i {\displaystyle T_{i}} that accesses an element from Right(y) and then an element from Left(y) (or vice versa) must touch the transition point of y {\displaystyle y} at least once. In the following Lemma, we will show that transition point is well-defined.

Lemma 1 — The transition point of a node y {\displaystyle y} in P {\displaystyle P} at a time i {\displaystyle i} exists and it is unique.[4]

Proof

Define {\displaystyle \ell } to be the lowest common ancestor of all nodes in T i {\displaystyle T_{i}} that are in Left(y). Given any two nodes a < b {\displaystyle a<b} in T i {\displaystyle T_{i}} , the lowest common ancestor of a {\displaystyle a} and b {\displaystyle b} , denoted by l c a ( a , b ) {\displaystyle lca(a,b)} , satisfies the following inequalities. a l c a ( a , b ) b {\displaystyle a\leq lca(a,b)\leq b} . Consequently, {\displaystyle \ell } is in Left(y), and {\displaystyle \ell } is the unique node of minimum depth in T i {\displaystyle T_{i}} . Same reasoning can be applied for r {\displaystyle r} , the lowest common ancestor of all nodes in T i {\displaystyle T_{i}} 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 {\displaystyle \ell } or r {\displaystyle r} . Suppose, it is {\displaystyle \ell } . Then, {\displaystyle \ell } is an ancestor of r {\displaystyle r} . Consequently, r {\displaystyle r} is a transition points since the path from the root to r {\displaystyle r} contains {\displaystyle \ell } . Moreover, any path in T i {\displaystyle T_{i}} from the root to a node in the sub-tree of y {\displaystyle y} must visit {\displaystyle \ell } because it is the ancestor of all such nodes, and for any path to a node in the right region must visit r {\displaystyle r} because it is lowest common ancestor of all the nodes in right(y). To conclude, r {\displaystyle r} is the unique transition point for y {\displaystyle y} in T i {\displaystyle T_{i}} .

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 y {\displaystyle y} . Suppose z {\displaystyle z} is the transition point of y {\displaystyle y} at a time j {\displaystyle j} . If an access algorithm for a BST does not touch z {\displaystyle z} in T i {\displaystyle T_{i}} for i [ j , k ] {\displaystyle i\in [j,k]} , then the transition point of y {\displaystyle y} will remain z {\displaystyle z} in T i {\displaystyle T_{i}} for i [ j , k ] {\displaystyle i\in [j,k]} . [4]

Proof

Consider the same definition for {\displaystyle \ell } and r {\displaystyle r} as in Lemma 1. Without loss of generality, suppose also that {\displaystyle \ell } is an ancestor of r {\displaystyle r} in the BST at time j {\displaystyle j} , denoted by T j {\displaystyle T_{j}} . As a result, r {\displaystyle r} will be the transition point of y {\displaystyle y} . By hypothesis, the BST algorithm does not touch the transition point, in our case r {\displaystyle r} , for the entirety of [ j , k ] {\displaystyle [j,k]} . Therefore, it does not touch any node in Right(y). Consequently, r {\displaystyle r} 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 i {\displaystyle i} , which we will denoted by i {\displaystyle \ell _{i}} . Even so, i {\displaystyle \ell _{i}} will remain the ancestor of r {\displaystyle r} for the following reasons: Firstly, observe that any node of Left(y) that was outside the tree rooted at r {\displaystyle r} at time j {\displaystyle j} cannot enter this tree at a time i [ j , k ] {\displaystyle i\in [j,k]} , since r {\displaystyle r} isn't touched in this time frame. Secondly, there exists at least one node i {\displaystyle \ell _{i}'} in Left(y) outside the tree rooted at r {\displaystyle r} , for any time i [ j , k ] {\displaystyle i\in [j,k]} . This is since {\displaystyle \ell } was initially outside r {\displaystyle r} 's sub-tree, and no nodes from outside the tree can enter it in this timeframe. Now, consider a i = l c a ( i , r ) {\displaystyle a_{i}=lca(\ell _{i}',r)} . a i {\displaystyle a_{i}} cannot be r {\displaystyle r} since i {\displaystyle \ell _{i}'} is not in the sub-tree of r {\displaystyle r} . So, a i {\displaystyle a_{i}} must be in Left(y), since i a i r {\displaystyle \ell _{i}'\leq a_{i}\leq r} . Consequently i {\displaystyle \ell _{i}} must be an ancestor of a i {\displaystyle a_{i}} and by consequence an ancestor of r {\displaystyle r} at time i {\displaystyle i} . Therefore, there always exists a node in Left(y) on the path from the root to r {\displaystyle r} , and as such r {\displaystyle r} remains the transition point.

The last Lemma toward the proof states that every node y P {\displaystyle y\in P} has its unique transition point.

Lemma 3 — Given a BST at time i {\displaystyle i} , T i {\displaystyle T_{i}} , any node y {\displaystyle y} in T i {\displaystyle T_{i}} can be only a transition for at most one node in P {\displaystyle P} .[4]

Proof

Given two distinct nodes y 1 , y 2 P {\displaystyle y_{1},y_{2}\in P} . Let r 1 , 1 , r 2 , 2 {\displaystyle r_{1},\ell _{1},r_{2},\ell _{2}} be the lowest common ancestor of R i g h t ( y 1 ) , L e f t ( y 1 ) , R i g h t ( y 2 ) , L e f t ( y 2 ) {\displaystyle Right(y_{1}),Left(y_{1}),Right(y_{2}),Left(y_{2})} respectively. From Lemma 1, we know that the transition point of y i {\displaystyle y_{i}} is either i {\displaystyle \ell _{i}} or r i {\displaystyle r_{i}} for i { 1 , 2 } {\displaystyle i\in \{1,2\}} . Now we have two main cases to consider.

Case 1: There is no ancestrally relation between y 1 {\displaystyle y_{1}} and y 2 {\displaystyle y_{2}} in P {\displaystyle P} . Consequently, the L e f t ( y 1 ) , L e f t ( y 2 ) , R i g h t ( y 1 ) , {\displaystyle Left(y_{1}),Left(y_{2}),Right(y_{1}),} and R i g h t ( y 2 ) {\displaystyle Right(y_{2})} are all disjoint. Thus, r 1 r 2 1 2 {\displaystyle r_{1}\neq r_{2}\neq \ell _{1}\neq \ell _{2}} , and the transition points are different.

Case 2: Suppose without loss of generality that y 1 {\displaystyle y_{1}} is an ancestor of y 2 {\displaystyle y_{2}} in P {\displaystyle P} .

Case 2.1: Suppose that the transition point of y 1 {\displaystyle y_{1}} is not in the tree rooted at y 2 {\displaystyle y_{2}} in P {\displaystyle P} . Thus, it is different from 2 {\displaystyle \ell _{2}} and r 2 {\displaystyle r_{2}} , and consequently the transition point of y 2 {\displaystyle y_{2}} .

Case 2.2: The transition point of y 1 {\displaystyle y_{1}} is in the tree rooted at y 2 {\displaystyle y_{2}} in P {\displaystyle P} . More precisely, it is one of the lowest common ancestor of L e f t ( y 2 ) {\displaystyle Left(y_{2})} and r i g h t ( y 2 ) {\displaystyle right(y_{2})} . In other words, it is either 2 {\displaystyle \ell _{2}} or r 2 {\displaystyle r_{2}} .

Suppose a 1 {\displaystyle a_{1}} is the lowest common ancestor of the sub-tree rooted at y 1 {\displaystyle y_{1}} and does not contain y 2 {\displaystyle y_{2}} . We have 2 {\displaystyle \ell _{2}} and r 2 {\displaystyle r_{2}} deeper than a 1 {\displaystyle a_{1}} because one of them is the transition point. Suppose that 2 {\displaystyle \ell _{2}} is the transition point. Then, 2 {\displaystyle \ell _{2}} is less deep that r 2 {\displaystyle r_{2}} . In this case, 2 {\displaystyle \ell _{2}} is the transition point of y 1 {\displaystyle y_{1}} and r 2 {\displaystyle r_{2}} is the transition point of y 2 {\displaystyle y_{2}} . Similar reasoning applies if r 2 {\displaystyle r_{2}} is less deep that 2 {\displaystyle \ell _{2}} . In sum, the transition point of y 1 {\displaystyle y_{1}} is the less deep from 2 {\displaystyle \ell _{2}} and r 2 {\displaystyle r_{2}} , and y 2 {\displaystyle y_{2}} 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 i {\displaystyle i} , any node y {\displaystyle y} in T i {\displaystyle T_{i}} can be only a transition for at most one node in P {\displaystyle P} . Thus, It is enough to count the number of touches of a transition node of y {\displaystyle y} , the sum over all y {\displaystyle y} .

Therefore, for a fixed node y P {\displaystyle y\in P} , let {\displaystyle \ell } and r {\displaystyle r} to be defined as in Lemma 1. The transition point of y {\displaystyle y} is among these two nodes. In fact, it is the deeper one. Let x i 1 , x i 2 , . . . , x i p {\displaystyle x_{i_{1}},x_{i_{2}},...,x_{i_{p}}} be a maximal ordered access sequence to nodes that alternate between L e f t ( y ) {\displaystyle Left(y)} and R i g h t ( y ) {\displaystyle Right(y)} . Then p {\displaystyle p} is the amount of interleaving through the node y {\displaystyle y} . Suppose that the even indexed accesses are in the L e f t ( y ) {\displaystyle Left(y)} , and the odd ones are in R i g h t ( y ) {\displaystyle Right(y)} i.e. x i 2 j L e f t ( y ) {\displaystyle x_{i_{2j}}\in Left(y)} and x i 2 j 1 R i g h t ( y ) {\displaystyle x_{i_{2j-1}}\in Right(y)} . We know by the properties of lowest common ancestor that an access to a node in L e f t ( y ) {\displaystyle Left(y)} , it must touch {\displaystyle \ell } . Similarly, an access to a node in R i g h t ( y ) {\displaystyle Right(y)} must touch r {\displaystyle r} . Consider every j [ 1 , p / 2 ] {\displaystyle j\in [1,\lfloor p/2\rfloor ]} . For two consecutive accesses x i 2 j 1 {\displaystyle x_{i_{2j-1}}} and x i 2 j {\displaystyle x_{i_{2j}}} , if they avoid touching the access point of y {\displaystyle y} , then {\displaystyle \ell } and r {\displaystyle r} 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 y {\displaystyle y} at least once in the interval of [ i 2 j 1 , i 2 j ] {\displaystyle [i_{2j-1},i_{2j}]} . Summing over all j [ 1 , p / 2 ] {\displaystyle j\in [1,\lfloor p/2\rfloor ]} , the best algorithm touches the transition point of y {\displaystyle y} at least p / 2 p / 2 1 {\displaystyle \lfloor p/2\rfloor \geq p/2-1} . Summing over all y {\displaystyle y} ,

      
  
    
      
        
          
          
            y
            
            P
          
        
        
          p
          
            y
          
        
        
          /
        
        2
        
        1
        
        I
        B
        (
        X
        )
        
          /
        
        2
        
        n
      
    
    {\displaystyle \sum _{y\in P}p_{y}/2-1\geq IB(X)/2-n}
  

where p y {\displaystyle p_{y}} is the amount of interleave through y {\displaystyle y} . By definition, the p y {\displaystyle p_{y}} 's add up to I B ( X ) {\displaystyle IB(X)} . That concludes the proof.

See also

References

  1. ^ Wilber, R. (1989). "Lower Bounds for Accessing Binary Search Trees with Rotations". SIAM Journal on Computing. 18: 56–67. doi:10.1137/0218004.
  2. ^ 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.
  3. ^ Patrascu, M.; Demaine, E. D. (2006). "Logarithmic Lower Bounds in the Cell-Probe Model" (PDF). SIAM Journal on Computing. 35 (4): 932. arXiv:cs/0502041. doi:10.1137/S0097539705447256.
  4. ^ a b c d e f Demaine, E. D.; Harmon, D.; Iacono, J.; Pătraşcu, M. (2007). "Dynamic Optimality—Almost" (PDF). SIAM Journal on Computing. 37: 240–251. doi:10.1137/S0097539705447347.
  5. ^ Demaine, Erik D.; Harmon, Dion; Iacono, John; Kane, Daniel; Pătraşcu, Mihai (2009), "The geometry of binary search trees", In Proceedings of the 20th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2009), New York: 496–505, doi:10.1137/1.9781611973068.55, ISBN 978-0-89871-680-1