The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion...
Transcript of The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion...
![Page 1: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/1.jpg)
The Geometry ofBinary Search Trees
Erik DemaineMIT
Dion HarmonNECSI
John IaconoPoly Inst. of NYU
Daniel KaneHarvard
Mihai PătraşcuIBM Almaden
![Page 2: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/2.jpg)
ASS
Point set in the plane
ASS = any nontrivial rectangle spanned by two points contains another point(interior or on boundary)
![Page 3: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/3.jpg)
MinASS Problem
Problem: Given a point set, find the minimum ASS superset▪ Up to constant factors,
can assume input points are in general position (no two horiz/vert aligned)
original pointsadded points
![Page 4: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/4.jpg)
MinASS in Worst Case
O(n lg n) points always suffice
Ω(n lg n) points are sometimes necessary(random; bit-reversal permutation matrix)
≤ n≤½n ≤½n≤¼n ≤¼n ≤¼n ≤¼n
![Page 5: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/5.jpg)
NP-completeness
Theorem:MinASS is NP-complete
OPEN:General positionMinASS
![Page 6: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/6.jpg)
Approximating MinASS
OPEN: O(1)-approximation?
Known: O(lg lg n)-approximation[and it’s not easy]
original pointsadded points
![Page 7: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/7.jpg)
GreedyASS
Imagine points arriving row by row
Add necessary points on the new rowto remain ASS
Conjecture:O(1)-approximation
original pointsadded points
![Page 8: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/8.jpg)
Binary Search Tree (BST)
Recall our good old friends:
Unit-cost operations:▪ Move finger up/left/right
▪ Rotate left/right
4
2 6
1 3 5 7
12
1410
1513119
8
4
2 5
1 3
2
41
53
![Page 9: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/9.jpg)
The Best BST
Problem:▪ Given (offline) access sequence S =x1, x2, …, xm
▪ OPT(S) = minimum sequence of unit-cost opsin BST to touch x1, x2, …, xm in order
Without rotations, this problem is solved by (static) optimal BSTs of Knuth [1971]
Ultimate goal:O(1)-competitive online algorithm
4
2 6
1 3 5 7
12
1410
1513119
8
![Page 10: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/10.jpg)
Example ofBST Execution
Access sequence:1, 4, 5, 7, 6, 2, 3
4
2 6
1 3 5 7
rotate
![Page 11: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/11.jpg)
Example ofBST Execution
Access sequence:1, 4, 5, 7, 6, 2, 3
42
6
1 3
57
![Page 12: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/12.jpg)
ASS/BST Equivalence
In fact, any ASS point set is a BST execution!▪ Treap by next
access time
Corollary: MinASS(S)= OPT(S)
1 2 3 4 5 6 7
1,2,4
5,6
7
3
![Page 13: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/13.jpg)
Attacks on OPT(S)
Splay trees [Sleator & Tarjan 1983]Conjecture: O(1)-competitiveMany nice properties known,but no o(lg n)-competitiveness known
Tango trees [Demaine, Harmon, Iacono, Pătraşcu 2004]
▪ O(lg lg n)-competitive
GreedyASS [Lucas 1988; Munro 2000]Proposed as offline BST algorithm(“Order by Next Request”)No o(n)-competitiveness known
![Page 14: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/14.jpg)
Online ASS/BST Equivalence
Theorem: If ASS sequence computed online row by row (like GreedyASS), then can convert to an online BST algorithm with constant-factor slowdown▪ Transform to geometry and back
Main ingredient: split trees▪ Support any sequence of n splits in O(n) time
▪ Splay trees take O(n (n)) time [Lucas 1988]
▪ Splay trees take O(n *(n)) time [Pettie 20??]
>x≤x
x
![Page 15: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/15.jpg)
New Dynamic Optimality Conjecture
GreedyASS is now an online algorithm!
Conjecture:GreedyASS is O(1)-competitive
Previously conjectured to be anoffline O(1)-approximation to OPT[Lucas 1988; Munro 2000]
![Page 16: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/16.jpg)
Lower Bounds
Need lower bounds on OPT(S) to compare algorithms (like GreedyASS) against
Wilber [1989] proved two lower bounds:▪ Wilber I used for O(lg lg n)-competitiveness
of Tango trees
▪ Wilber II used for key-independent optimality [Iacono 2002]
▪Conjecture: Wilber II ≥ Wilber I
▪Conjecture: OPT(S) = Θ(Wilber II)
![Page 17: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/17.jpg)
Independent Set Lower Bounds
Wilber I and Wilber II fall in the (new) class of independent rectangle bounds
Theorem: MinASS(S) = Ω(largest independent rectangle set)
What is the best lower bound in this class?
independent dependent
![Page 18: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/18.jpg)
SignedGreedy
Max of:
original pointsadded points
original pointsadded points
original pointsadded points
Just fix empty positive-slope rectangles
Just fix empty negative-slope rectangles
+ −
![Page 19: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/19.jpg)
Lower Bounds: SignedGreedy
Theorem: SignedGreedy(S) is withina constant factor of the bestindependent rectangle bound
Corollary:▪ OPT(S) ≥ SignedGreedy(S)
▪ SignedGreedy(S) = Ω(Wilber I + WilberII)
SignedGreedy (lower bound) is annoyingly similar to GreedyASS (upper bound)
![Page 20: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/20.jpg)
Open Problems
Does GreedyASS share all the nice properties of splay trees?▪Recent result: [Iacono & Pătraşcu]
GreedyASS satisfies access theorem(from splay trees)
working-set boundentropy boundstatic finger boundO(lg n) amortized per operation
▪ Anyone for dynamic finger?
![Page 21: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/21.jpg)
Open Problems
Hardness of approximability
NP-hardness of general position
![Page 22: The Geometry of Binary Search Trees · The Geometry of Binary Search Trees Erik Demaine MIT Dion Harmon NECSI John Iacono Poly Inst. of NYU Daniel Kane Harvard Mihai Pătraşcu IBM](https://reader036.fdocuments.net/reader036/viewer/2022070702/5e61e6d81ad28b461e332f0f/html5/thumbnails/22.jpg)
P.S.
ASS = Arborally Satisfied Set
[Arboral = arboreal = related to trees]