Lexi Trees: Probabilistic and Deterministic Self-Balancing Binary Search Trees

Massimiliano Tomassoli, 2022
GitHub repository

1. In a nutshell

2. Exposition

3. List Trees

Take a look at the following randomly-generated List Tree:

3.1. About the pictures

4. Lexi Trees

4.1. Rules for the arrows

Here are a few examples:



Here's a bigger one, but without labels for lack of space:

4.2. Operations

5. P‑Lexi Trees

5.1. P‑Lexi Trees are isomorphic to Skip Lists

5.1.1. Proof (sketch)

5.2. Why do Skip Lists work?

Here's my intuition:

5.3. Operations

5.3.1. Nodes

5.3.2. Search Paths

5.3.3. Insertions

5.3.4. Deletions

5.4. Parallelization

6. kk-Lexi Trees

7. 2‑Lexi Trees

7.1. Insertion

7.2. Deletion

7.3. Additional Remarks

7.4. Parallelization

8. 3‑Lexi Trees

8.1. Insertion

8.2. Deletion

8.3. Additional Remarks

8.4. Parallelization

8.4.1. High Level

8.4.2. Low Level

8.4.2.1. Versioning
8.4.2.2. Locking
8.4.2.3. Deletions

9. Implementations

9.1. P‑Lexi Trees

9.2. 2- and 3‑Lexi Trees

9.2.1. Case I of lift in lift.py

# Case I: prev.right = cur
# P            ==>  P --> r
#  \           ==>       / \
#   c  r  r2   ==>      c   r2
#     /        ==>       \ 

9.2.2. Case II of lift in lift.py

# Case II: prev.left = cur
# P2 ------------.   P2  ==>  P2 ---.   .-------- P2
#                 \ /    ==>         \ /
# P2 ------------> P     ==>  P2 ---> r ---> P
#        _________/      ==>         /      / 
#       /                ==>        /      /
#      c   r   r2        ==>       c     r2
#     /   /              ==>      / \
# NOTE: Prev2 can be in any of the 3 positions shown above.

9.2.3. Case Right of lower in lower3.py

# Case Right3
# P --.    .------------ P  ==>  P ----------.    .----- P
#      \  /                 ==>               \  /
# P --> c1 - - - - - > r    ==>  P ----------> o2 - -> r
#      /  \    _ _ _ _/     ==>       ________/  \    /
#     /    \  /             ==>      /            \  /
#   c2      o1  o2  o3      ==>     c2  c1  o1     o3
#     \    /   /            ==>        /   /  \
#
# Case Right2
# P ---.    .--------- P  ==>  P -------.    .----- P
#       \  /              ==>            \  /
# P ---> c1 - - - -> r    ==>  P -------> o1 - -> r
#       /  \    _ _ /     ==>        ____/  \    /
#      /    \  /          ==>       /        \  /
#    c2      o1  o2       ==>      c2  c1     o2
#      \    /             ==>         /  \  

9.2.4. Remarks

10. Tests & Statistics

10.1. Tests

10.2. Key Pickers

10.3. Statistics

10.3.1. Method

10.3.2. Results

Thanks

Thank you for reading this! I hope you had a good time 😃