turning amortized to worst-case data structures: techniques and results tsichlas kostas
TRANSCRIPT
![Page 1: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/1.jpg)
Turning Amortized to Worst-Case Data Structures: Techniques and
Results
Tsichlas Kostas
![Page 2: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/2.jpg)
Talk Structure Techniques
Guaranteed Complexities of Data Structures:
– The finger search tree problem
[STOC 02, Brodal, Lagogiannis, Makris, Tsakalidis, Tsichlas]
– The merge of search trees problem
[ESA 06, Brodal, Makris, Tsichlas]
Open Problems
![Page 3: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/3.jpg)
Amortized vs Worst-Case Complexities
Amortized: N operations on a set of n elements cost O(f(N,n)) time,– The mean cost of each operation is O(f(N,n)/N)– There may be operations which are expensive
Worst-Case: Each operation costs O(g(n)).– Usually more complicated design that amortized
structures
Question: g(N)=O(f(N,n)/N) (????)
amortized
worst-case
![Page 4: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/4.jpg)
Conversion Techniques to Worst-Case Complexities
Incremental Scheduling of Operations:
– Redundant Number Systems
– Stricter Invariants on the structure
– Local or Global Rebuilding
![Page 5: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/5.jpg)
Redundant Number Systems
For each number there is only one representation (usual number systems)
For each number there are multiple representations (redundant number systems)
![Page 6: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/6.jpg)
How do we Count?
1
0
1
1
0
1
30
MSB
LSB
+1
0
0
0
0
1
0
32
6 Ops
-1
1
1
1
1
0
1
31
6 Ops
-1
1
0
1
1
0
1
30
1 Op
+1
1
1
1
1
0
1
31
1 Op
![Page 7: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/7.jpg)
A New Way to Count Use 3 digits {0,1,2}, where 2
represents the carry. Between two 2s there is always a
zero The first digit from the LSB
different to 1 is always a 0 Fix(dj) If dj = 2 then dj = 0 και dj+1
= dj+1+1
Increase(x)
1. x = x+1
2. i = min{j:dj1}
3. Fix(dj)
1
0
1
2
0
1
546
MSB
LSB
0
1
2
+1
1
1
1
2
0
1
547*
0
1
2
Fix
1
1
2
0
0
1
547
0
1
2
![Page 8: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/8.jpg)
+ and -Use 4 digits {-1,0,1,2}, where 2 represents the carry and -1 the residue.
1
1
0
-1
0
2
31
+1
2
0
0
-1
0
2
32
2 Ops
0
1
0
0
0
2
33
2 Ops
+1
1
1
0
-1
0
2
31
-1
1
0
-1
1
0
2
30
2 Ops
0
1
-1
1
0
2
29
2 Ops
-1
0
0
1
1
0
1
28
-1
2 Ops
![Page 9: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/9.jpg)
MSB
LSB
Simple Counters on (2,3)-trees
--A node has 3 children 1
--A node has 2 children 0
1
1
1
1
1
0
0
1
0
0
0
0
![Page 10: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/10.jpg)
MSB
LSB
Redundant Counters on (2,3)-trees
--A node has 3 children 1 --A node has 4 children 2
--A node has 2 children 0 --A node has 1 child -1
1
1
0
-1
1
2
2
0
![Page 11: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/11.jpg)
What about Arbitrary Updates?
Redundant number representation cannot be used in this case because of the tree structure.
Somehow we must come up with a “tree counter”
![Page 12: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/12.jpg)
Known Results Insertion Deletion Search
AVL-trees, (2,3)-trees (a)
Red-Black trees, (2,4)-trees (a,b)
Levcopoulos, Overmars ’88 (a)
Guibas et al. ’77, Tsakalidis ’85 (a,c)
Harel, Lucker ’79 (a)
Huddleston, Mehlhorn ’82 (a,b)
Brodal ’98 (a)
Brodal et al. ’02(a)
Dietz, Raman ’94 (d)
Andersson, Thorup ’00 (e)
d
dO
loglog
log
nO log nO log
nO log
nO log
dO log
dO log
dO log
dO log
dO log
dO log
1O
1O
1O
nO *log
1O
1O
1O
1O
1O
nO *log
(a) Pointer Machine (b) Amortized Complexity (c) O(1) Movable Fingers
(d) Comparison RAM (e) Word RAM
![Page 13: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/13.jpg)
Components
•Mechanism to identify where to rebalance •Components = partition of internal nodes into subtrees
4 5 6 8 9 11 13 15 17 19 21 23 24 27 31 33 34 35 37 41 42 51 53
Link(v)
v
Break(r)r
Link(v)
•Component records with root pointers (valid or invalid)
![Page 14: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/14.jpg)
Catenable Sorted Lists in Worst-Case Constant Time
![Page 15: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/15.jpg)
Catenable Sorted Lists
Insert(T,x) Delete(T,x) Search(T,x) Join(T1,T2 ) Split(T,x)
T1 = 2,5,7,8,10,11 T2 = 13,17,19,34,58,79
Join(T1,T2 ) = 2,5,7,8,10,11,13,17,19,34,58,79
This talk
![Page 16: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/16.jpg)
31 33 34 35 37 41 42 51 53
root
Catenable Sorted Lists: Search Trees (2,3-trees)
58 60 61 64 67 71 72 74 75
1. Search for appropriate position
2. Link
3. RebalanceT1
T2
![Page 17: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/17.jpg)
Catenable Sorted Lists: Search Trees
(2,4-trees, red-black trees…)
T1
T2
1
3
2
Search
Link
Rebalance
1
2
3
Worst-case O(1)
Worst-case O(log |T1|)
Worst-case O(log |T2|)
or amortized O(1)
or O(loglog |T2|)
or worst-case O(1)
or amortized O(1)
![Page 18: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/18.jpg)
Catenable Sorted Lists
Search trees
Kaplan
Tarjan’96
This talk
Search log n log n log n
Insert/Delete log n log n log n
Join log n 1* loglog ns 1
Split log n log ns -
n = |T| ns = min(|T1|,|T2|) * amortized
![Page 19: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/19.jpg)
O(1) Join and O(log n) Search
The ideas….
![Page 20: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/20.jpg)
Problem: Nodes of arbitrary degree
Idea 1: Linking By Size
T1 T2
height O(log n)
![Page 21: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/21.jpg)
Idea 2: Represent Nodes byWeight-Balanced Trees
Problem: Does not support linking by size in O(1) time
O(log n)O(log n)
![Page 22: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/22.jpg)
Idea 3: Tree-Collections and Lazy Join
Tree collection
k treesk levels
Weight- balanced tree
![Page 23: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/23.jpg)
Idea 3 (cont.): Lazy Join
Old tree collection
New tree collection
k treesk levels
![Page 24: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/24.jpg)
Conclusion
Search trees This talk ♪
Search log n log n
Insert/Delete log n log n
Join log n 1* 1
Split log n -
* amortized ♪ purely functional
![Page 25: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/25.jpg)
Open ProblemsVery Hard…
• Dynamic Fractional Cascading (O(loglogn) worst-case)
• Full Persistence (O(1) worst-case)
• …
Hard…
• Simple Constant Update Finger Trees
• Support the split operation in the constant catenable sorted list
• …
![Page 26: Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas](https://reader035.vdocuments.mx/reader035/viewer/2022081518/5515de10550346cf6f8b4bb6/html5/thumbnails/26.jpg)
Finger Searching in (2,4)-trees
Insertion: O(logn) w.c.t.
Deletion: O(logn) w.c.t.
Search: O(logd) w.c.t.
1. Search
2. Update
3. Rebalance
Update Operations:
4 5 6 8 9 11 13 15 17 19 21 23 24 27 31 33 34 35 37 41 42 51 53
10f’ x
d=7f
root