The Nearest Colored Node in a Tree

The Nearest Colored Node in a Tree
Paweł Gawrychowski, Gad M. Landau, Shay Mozes, Oren Weimann
The Nearest Colored Node in a Tree
v
dist(v, )
Paweł Gawrychowski, Gad M. Landau, Shay Mozes, Oren Weimann
The Nearest Colored Node in a Tree
v
dist(v, )
Paweł Gawrychowski, Gad M. Landau, Shay Mozes, Oren Weimann
The Nearest Colored Node in a Tree
v
dist(v, )
Paweł Gawrychowski, Gad M. Landau, Shay Mozes, Oren Weimann
Vertex-Colored Network
•
Colors indicate functionality of a node.
Vertex-Colored Network
•
Colors indicate functionality of a node.
road
network
Vertex-Colored Network
•
Colors indicate functionality of a node.
computer
network
Vertex-Colored Distance Oracle
Vertex-Colored Distance Oracle
•
Data Structure for queries:
“what’s the closest red node to node v”
v
Vertex-Colored Distance Oracle
•
Data Structure for queries:
“what’s the closest red node to node v”
v
Trees
Trees
5
1
1
5
3
5
9
2
4
13
23
7
1
21
Trees
Trees
•
Nearest colored node
v
Trees
•
•
Nearest colored descendant
Nearest colored node
v
Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
If number of colors is O(logn) there is an optimal
O(n)-space O(1)-query solution
[Bille, Landau, Raman, Rao, Sadakane, W. 2011]
v
Static Trees
Implicit in [Belazzougui, Navarro 2010]:
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Ω(log log n)-query for any
O(n polylog n)-space solution
Static Trees
Implicit in [Belazzougui, Navarro 2010]:
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. Assign preorder numbers
1
2
3
4
5
9
6
7
10
8 11
12
13
14 15
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. Assign preorder numbers
2. For every color: store these numbers in predecessor data structure
(given v find interval of all vertices in its subtree)
1
2
3
4
5
9
6
7
v
10
8 11
12
13
14 15
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. Assign preorder numbers
2. For every color: store these numbers in predecessor data structure
(given v find interval of all vertices in its subtree)
plus RMQ data structure (weight = dist. from root)
1
2
3
4
5
9
6
7
v
10
8 11
12
13
14 15
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1
2
3
4
5
9
6
7
v
10
8 11
12
13
14 15
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. Assign preorder and postorder numbers
1
2
3
4
5
9
6
7
v
10
8 11
12
13
14 15
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. Assign preorder and postorder numbers
1,30
2,15
3,8
6,7
4,5
16,29
9,14
v
12,13
10,11
17,22
23,28
20,21
18,19
26,27
24,25
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. Assign preorder and postorder numbers
2. For every color: store these numbers in predecessor data structure
1,30
2,15
3,8
6,7
4,5
16,29
9,14
v
12,13
10,11
17,22
23,28
20,21
18,19
26,27
24,25
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. Assign preorder and postorder numbers
2. For every color: store these numbers in predecessor data structure
plus nearest ancestor with the same color
1,30
2,15
3,8
6,7
4,5
16,29
9,14
v
12,13
10,11
17,22
23,28
20,21
18,19
26,27
24,25
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
Linear size in #
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
2. Now use the nearest colored ancestor & descendant solutions
Linear size in #
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
2. Now use the nearest colored ancestor & descendant solutions
Linear size in #
v
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
2. Now use the nearest colored ancestor & descendant solutions
✅
v
Linear size in #
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
2. Now use the nearest colored ancestor & descendant solutions
Linear size in #
v
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
2. Now use the nearest colored ancestor & descendant solutions
?
v
?
Linear size in #
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
2. Now use the nearest colored ancestor & descendant solutions
?
✅
v
?
Linear size in #
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
2. Now use the nearest colored ancestor & descendant solutions
Linear size in #
v
Static Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Ω(log log n)-query for any
O(n polylog n)-space solution
O(log log n)-query
O(n)-space solution
1. For every color: consider all nodes of this color and their LCAs
and all edges (paths) between them
plus nearest node with this color
2. Now use the nearest colored ancestor & descendant solutions
?
?
Linear size in #
v
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Dynamic Trees
[Alstrup, Husfeldt, Rauhe, 1998]:
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
Dynamic Trees
[Alstrup, Husfeldt, Rauhe, 1998]:
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
[Alstrup, Husfeldt, Rauhe, 1998]:
O(log log n)-update
O(logn / loglog n)-query
O(n)-space
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
O(polylog n)-update requires
Ω(logn / loglog n)-query
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
Lower bound via three simple reductions:
v
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
Lower bound via three simple reductions:
dynamic nearest
colored ancestor
v
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
Lower bound via three simple reductions:
dynamic nearest
dynamic planar
→
colored ancestor
dominance emptiness
y
✓
?
v
x
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
Lower bound via three simple reductions:
dynamic nearest
dynamic planar
dynamic Suffix
→
→
colored ancestor
dominance emptiness Minimum Queries
y
✓
2 0 4 3 5 1 7 6
?
SMQ?
v
x
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
Lower bound via three simple reductions:
dynamic nearest
dynamic nearest
dynamic planar
dynamic Suffix
→
→
→
colored ancestor
dominance emptiness Minimum Queries colored descendant
y
✓
2 0 4 3 5 1 7 6
?
SMQ?
v
x
v
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
O(log2/3 n)-update
O(logn / loglog n)-query
O(n)-space
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
O(log2/3 n)-update
O(logn / loglog n)-query
O(n)-space
1. Assign preorder and postorder numbers
1,30
2,15
3,8
6,7
4,5
16,29
9,14
v
12,13
10,11
17,22
23,28
20,21
18,19
26,27
24,25
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
O(log2/3 n)-update
O(logn / loglog n)-query
O(n)-space
1. Assign preorder and postorder numbers
2. For every color: store points (pre(u), dist(u,root)) in the 3-sided planar
d
d
emptiness structure of [Wilkinson 2014]
1,30
dist(u,root)
2,15
3,8
6,7
4,5
16,29
u
9,14
v
12,13
10,11
17,22
23,28
20,21
18,19
26,27
24,25
pre(u)
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
O(log2/3 n)-update
O(logn / loglog n)-query
O(n)-space
1. Assign preorder and postorder numbers
2. For every color: store points (pre(u), dist(u,root)) in the 3-sided planar
d
d
emptiness structure of [Wilkinson 2014]
1,30
dist(u,root)
2,15
3,8
6,7
4,5
16,29
u
9,14
v
12,13
10,11
17,22
23,28
20,21
18,19
26,27
24,25
✓
pre(v) post(v)
pre(u)
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
O(polylog n)-update requires
Ω(logn / loglog n)-query
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
dynamic nearest
colored ancestor
v
O(polylog n)-update requires
Ω(logn / loglog n)-query
dynamic nearest
colored node
v
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
dynamic nearest
colored ancestor
v
Blow up the lower bound
tree weights exponentially
so that nearest colored
node is always an ancestor
O(polylog n)-update requires
Ω(logn / loglog n)-query
dynamic nearest
colored node
v
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
O(polylog n)-update requires
Ω(logn / loglog n)-query
O(log n)-update
O(log n)-query
O(n)-space
Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
O(polylog n)-update requires
Ω(logn / loglog n)-query
O(log n)-update
O(log n)-query
O(n)-space
Most technical part of the paper:
Uses all of the above machinery plus a hybrid of Centroid
decomposition and Top Trees, augmented with nearest colored
centroid and with LCA…
v
Fully Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Fully Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Fully Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
Fully Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
Fully Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
v
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
Fully Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
APSP
a1
b1
a2
b2
a3
b3
an
bn
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
Fully Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
APSP
a1
b1
a2
b2
a3
b3
an
bn
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
Fully Dynamic Trees
•
•
•
Nearest colored ancestor
Nearest colored descendant
Nearest colored node
APSP
a1
a2
a3
an
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
Tree with n2 vertices and #colors = n
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
Tree with n2 vertices and #colors = n
What’s the closest blue to a3 ?
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
Tree with n2 vertices and #colors = n
What’s the closest blue to a3 ?
What’s the closest red to a3 ?
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
Tree with n2 vertices and #colors = n
a2
b1
b2
b3
a3
bn
What’s the closest blue to a3 ?
an
b1
b2
b3
What’s the closest red to a3 ?
…
bn
b1
b2
b3
bn
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
Tree with n2 vertices and #colors = n
a2
b1
b2
b3
a3
bn
What’s the closest blue to a3 ?
an
b1
b2
b3
What’s the closest red to a3 ?
…
bn
b1
b2
b3
bn
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
Tree with n2 vertices and #colors = n
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
Tree with n2 vertices and #colors = n
What’s the closest blue to a2 ?
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
Tree with n2 vertices and #colors = n
What’s the closest blue to a2 ?
What’s the closest red to a2 ?
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
Tree with n2 vertices and #colors = n
a2
b1
b2
b3
a3
bn
What’s the closest blue to a2 ?
an
b1
b2
b3
What’s the closest red to a2 ?
…
bn
b1
b2
b3
bn
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
a2
b1
b2
b3
a3
bn
an
b1
b2
b3
bn
b1
b2
b3
bn
Tree with n2 vertices and #colors = n
Overall:
n2 updates and n2 queries
Fully Dynamic Trees
O(#colors1-𝜺) query and update
implies an O(n3-𝜺) for APSP
[Alstrup, Holm, de-Lichtenberg, Thorup 2005]
b1
b2
b3
bn
O(#colors ⋅ log n)-update
O(log n)-query
O(n)-space
b1
b2
b3
bn
a1
Tree with n2 vertices and #colors = n
a2
b1
b2
b3
a3
bn
Overall:
n2 updates and n2 queries
an
b1
b2
b3
If we could do each in less than
bn
#colors1-𝜺 = n1-𝜺 time then total is n3-𝜺
b1
b2
b3
bn
Open Problems
•
•
Nearest colored descendant
O(log2/3 n)-update
O(logn / loglog n)-query
O(n)-space
Nearest colored node
O(log n)-update
O(log n)-query
O(n)-space
Toh-dah !