21.09.2015
Introduction CS Background
Given: Words, e.g. in binary code
Ξ
1= 11010 . . . , Ξ
2= 00011 . . . , Ξ
3= 01101 . . . , Ξ
4= 00000 . . . , Ξ
5= 11111 . . . , Ξ
6= 11100 . . .
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 2 / 19
Introduction CS Background
Given: Words, e.g. in binary code
Ξ
1= 11010 . . . , Ξ
2= 00011 . . . , Ξ
3= 01101 . . . , Ξ
4= 00000 . . . , Ξ
5= 11111 . . . , Ξ
6= 11100 . . .
Task: Storage that allows fast search and insert/delete operations
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 2 / 19
Introduction CS Background
Given: Words, e.g. in binary code
Ξ
1= 11010 . . . , Ξ
2= 00011 . . . , Ξ
3= 01101 . . . , Ξ
4= 00000 . . . , Ξ
5= 11111 . . . , Ξ
6= 11100 . . .
Task: Storage that allows fast search and insert/delete operations
→ Use tree-like data structures such as a Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 2 / 19
Ξ
1= 11010 . . . , Ξ
2= 00011 . . . , Ξ
3= 01101 . . . , Ξ
4= 00000 . . . , Ξ
5= 11111 . . . , Ξ
6= 11100 . . .
Task: Storage that allows fast search and insert/delete operations
→ Use tree-like data structures such as a Trie (Information retrieval)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 2 / 19
Introduction CS Background
Constructing a Trie
Ξ
1= 11010 . . . , Ξ
2= 00011 . . . , Ξ
3= 01101 . . . , Ξ
4= 00000 . . . , Ξ
5= 11111 . . . , Ξ
6= 11100 . . .
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 3 / 19
Introduction CS Background
Constructing a Trie
Ξ
1= 11010 . . . , Ξ
2= 00011 . . . , Ξ
3= 01101 . . . , Ξ
4= 00000 . . . , Ξ
5= 11111 . . . , Ξ
6= 11100 . . .
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 3 / 19
Introduction CS Background
Constructing a Trie
Ξ
1= 11010 . . . , Ξ
2= 00011 . . . , Ξ
3= 01101 . . . , Ξ
4= 00000 . . . , Ξ
5= 11111 . . . , Ξ
6= 11100 . . .
Ξ1
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 3 / 19
Ξ4 Ξ2 Ξ3 Ξ1 Ξ6 Ξ5
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 3 / 19
Introduction CS Background
Constructing a Trie
Ξ
1= 11010 . . . , Ξ
2= 00011 . . . , Ξ
3= 01101 . . . , Ξ
4= 00000 . . . , Ξ
5= 11111 . . . , Ξ
6= 11100 . . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 3 / 19
Introduction CS Background
Searching
Search for Ξ
1= 11010 . . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1Worst case = Height of the Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Introduction CS Background
Searching
Search for Ξ
1= 11010 . . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1Worst case = Height of the Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Introduction CS Background
Searching
Search for Ξ
1=
11010. . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1Worst case = Height of the Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Introduction CS Background
Searching
Search for Ξ
1=
11010. . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1Worst case = Height of the Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Introduction CS Background
Searching
Search for Ξ
1=
11010. . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1Worst case = Height of the Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Introduction CS Background
Searching
Search for Ξ
1=
11010. . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1= 3
= Shortest prefix of Ξ
1not shared by Ξ
2, . . . , Ξ
6Worst case = Height of the Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Introduction CS Background
Searching
Search for Ξ
1=
11010. . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1= 3
= Shortest prefix of Ξ
1not shared by Ξ
2, . . . , Ξ
6Worst case = Height of the Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Introduction CS Background
Searching
Search for Ξ
1=
11010. . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1= Shortest prefix of Ξ
1not shared by Ξ
2, . . . , Ξ
6Worst case = Height of the Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Introduction CS Background
Searching
Search for Ξ
1=
11010. . .
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1= 3
= Shortest prefix of Ξ
1not shared by Ξ
2, . . . , Ξ
6Worst case = Height of the Trie
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Searching cost = Depth of Ξ
1= 3
= Shortest prefix of Ξ
1not shared by Ξ
2, . . . , Ξ
6Worst case = Height of the Trie = 4
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 4 / 19
Introduction The Probabilistic Model
Input Model
Generate the words Ξ
1, Ξ
2, . . . to be stored → Probabilistic Model
The words Ξ
1, Ξ
2, . . . are independent and identically distributed
Each word Ξ
i= ξ
1ξ
2ξ
3ξ
4. . . consists of letters ξ
1, ξ
2, . . . that are:
More general models allow ξ
1, ξ
2, . . . to be dependent (e.g. evolving as a Markov chain)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 5 / 19
Introduction The Probabilistic Model
Input Model
Generate the words Ξ
1, Ξ
2, . . . to be stored → Probabilistic Model The words Ξ
1, Ξ
2, . . . are independent and identically distributed
Each word Ξ
i= ξ
1ξ
2ξ
3ξ
4. . . consists of letters ξ
1, ξ
2, . . . that are:
More general models allow ξ
1, ξ
2, . . . to be dependent (e.g. evolving as a Markov chain)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 5 / 19
Introduction The Probabilistic Model
Input Model
Generate the words Ξ
1, Ξ
2, . . . to be stored → Probabilistic Model The words Ξ
1, Ξ
2, . . . are independent and identically distributed Each word Ξ
i= ξ
1ξ
2ξ
3ξ
4. . . consists of letters ξ
1, ξ
2, . . . that are:
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 5 / 19
Introduction The Probabilistic Model
Input Model
Generate the words Ξ
1, Ξ
2, . . . to be stored → Probabilistic Model The words Ξ
1, Ξ
2, . . . are independent and identically distributed Each word Ξ
i= ξ
1ξ
2ξ
3ξ
4. . . consists of letters ξ
1, ξ
2, . . . that are:
• independent,
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 5 / 19
Introduction The Probabilistic Model
Input Model
Generate the words Ξ
1, Ξ
2, . . . to be stored → Probabilistic Model The words Ξ
1, Ξ
2, . . . are independent and identically distributed Each word Ξ
i= ξ
1ξ
2ξ
3ξ
4. . . consists of letters ξ
1, ξ
2, . . . that are:
• independent, • P(ξ
j= 0) = 1 /2 = P(ξ
j= 1)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 5 / 19
Generate the words Ξ
1, Ξ
2, . . . to be stored → Probabilistic Model The words Ξ
1, Ξ
2, . . . are independent and identically distributed Each word Ξ
i= ξ
1ξ
2ξ
3ξ
4. . . consists of letters ξ
1, ξ
2, . . . that are:
• independent, • P(ξ
j= 0) = 1 /2 = P(ξ
j= 1)
More general models allow ξ
1, ξ
2, . . . to be dependent (e.g. evolving as a Markov chain)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 5 / 19
Ξ1
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ1, Ξ2
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2
Ξ1
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ1, Ξ2
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2
Ξ1
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2 Ξ1
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ3
Ξ2 Ξ1
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2 Ξ1
Ξ3
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ4
Ξ2 Ξ1
Ξ3
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ4
Ξ2 Ξ1
Ξ3
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2 Ξ1, Ξ4
Ξ3
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2 Ξ4
Ξ1
Ξ3
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2
Ξ1 Ξ4
Ξ3
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ5
Ξ2
Ξ1 Ξ4
Ξ3
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2
Ξ1 Ξ4
Ξ3, Ξ5
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2
Ξ1 Ξ4
Ξ5
Ξ3
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2
Ξ1 Ξ4
Ξ3, Ξ5
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2
Ξ1 Ξ4
Ξ5
Ξ3
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Ξ2
Ξ1 Ξ4 Ξ3 Ξ5
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 6 / 19
Analysis The Depth
Consider n words Ξ
1, . . . , Ξ
n. What is the depth of the vertex Ξ
1?
Recall:
Depth D
n= Length of the shortest unique prefix of Ξ
1= ξ
1ξ
2ξ
3. . . P(D
n≤ k) = P(Ξ
2, . . . , Ξ
ndo not start with ξ
1. . . ξ
k)
Consequence:
P(D
n≤ α log
2(n)) = 1 − n
−αn−1n→∞
−→
( 1, if α > 1, 0, if α < 1.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 7 / 19
Analysis The Depth
Consider n words Ξ
1, . . . , Ξ
n. What is the depth of the vertex Ξ
1? Recall:
Depth D
n= Length of the shortest unique prefix of Ξ
1= ξ
1ξ
2ξ
3. . .
P(D
n≤ k) = P(Ξ
2, . . . , Ξ
ndo not start with ξ
1. . . ξ
k)
Consequence:
P(D
n≤ α log
2(n)) = 1 − n
−αn−1n→∞
−→
( 1, if α > 1, 0, if α < 1.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 7 / 19
Analysis The Depth
Consider n words Ξ
1, . . . , Ξ
n. What is the depth of the vertex Ξ
1? Recall:
Depth D
n= Length of the shortest unique prefix of Ξ
1= ξ
1ξ
2ξ
3. . . P(D
n≤ k) = P(Ξ
2, . . . , Ξ
ndo not start with ξ
1. . . ξ
k)
= 1 − 1 2
k!
n−1Consequence:
P(D
n≤ α log
2(n)) = 1 − n
−αn−1Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 7 / 19
Analysis The Depth
Consider n words Ξ
1, . . . , Ξ
n. What is the depth of the vertex Ξ
1? Recall:
Depth D
n= Length of the shortest unique prefix of Ξ
1= ξ
1ξ
2ξ
3. . . P(D
n≤ k) = P(Ξ
2, . . . , Ξ
ndo not start with ξ
1. . . ξ
k)
= 1 − 1 2
k!
n−1Consequence:
P(D
n≤ α log
2(n)) = 1 − n
−αn−1Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 7 / 19
Analysis The Depth
Consider n words Ξ
1, . . . , Ξ
n. What is the depth of the vertex Ξ
1? Recall:
Depth D
n= Length of the shortest unique prefix of Ξ
1= ξ
1ξ
2ξ
3. . . P(D
n≤ k) = P(Ξ
2, . . . , Ξ
ndo not start with ξ
1. . . ξ
k)
= 1 − 1 2
k!
n−1Consequence:
P(D
n≤ α log
2(n)) = 1 − n
−αn−1Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 7 / 19
Depth D
n= Length of the shortest unique prefix of Ξ
1= ξ
1ξ
2ξ
3. . . P(D
n≤ k) = P(Ξ
2, . . . , Ξ
ndo not start with ξ
1. . . ξ
k)
= 1 − 1 2
k!
n−1Consequence:
P(D
n≤ α log
2(n)) = 1 − n
−αn−1 n→∞−→
( 1, if α > 1, 0, if α < 1.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 7 / 19
Analysis The Depth
Results on D
nShown on the previous slide:
D
nlog
2(n)
−→ 1
P(n → ∞)
Thm (Knuth ’72): E[D
n] = log
2(n) + Ψ(log
2(n)) + o(1) with periodic function Ψ
Thm (Szpankowski ’86): Var(D
n) ∼ Φ(log
2(n)) with periodic function Φ
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 8 / 19
Analysis The Depth
Results on D
nShown on the previous slide:
D
nlog
2(n)
−→ 1
P(n → ∞) Considering the previous slide more carefully:
P (D
n− log
2(n) < x) ≈
1 − 2
−xn
n−1n→∞
−→ e
−2−x(Limit is a Gumbel distribution known from extreme value theory)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 8 / 19
Analysis The Depth
Results on D
nShown on the previous slide:
D
nlog
2(n)
−→ 1
P(n → ∞) Considering the previous slide more carefully:
P (D
n− log
2(n) < x) ≈
1 − 2
−xn
n−1n→∞
−→ e
−2−x(Limit is a Gumbel distribution known from extreme value theory) Thm (Knuth ’72): E[D
n] = log
2(n) + Ψ(log
2(n)) + o(1)
with periodic function Ψ
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 8 / 19
D
nlog
2(n)
−→ 1
P(n → ∞) Considering the previous slide more carefully:
P (D
n− log
2(n) < x) ≈
1 − 2
−xn
n−1n→∞
−→ e
−2−x(Limit is a Gumbel distribution known from extreme value theory) Thm (Knuth ’72): E[D
n] = log
2(n) + Ψ(log
2(n)) + o(1)
with periodic function Ψ
Thm (Szpankowski ’86): Var(D
n) ∼ Φ(log
2(n)) with periodic function Φ
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 8 / 19
Analysis The Height
Consider n words Ξ
1, . . . , Ξ
n. What is the height of the resulting Trie?
Def: Height H
n= max{D
n(Ξ
i) : i = 1, . . . , n}. The result P(D
n≤ k) = (1 − 2
−k)
n−1implies:
P (H
n> α log
2(n)) =
Consequence: P (H
n> α log
2(n)) → 0 for α > 2
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 9 / 19
Analysis The Height
Consider n words Ξ
1, . . . , Ξ
n. What is the height of the resulting Trie?
Def: Height H
n= max{D
n(Ξ
i) : i = 1, . . . , n}.
The result P(D
n≤ k) = (1 − 2
−k)
n−1implies: P (H
n> α log
2(n)) =
Consequence: P (H
n> α log
2(n)) → 0 for α > 2
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 9 / 19
Analysis The Height
Consider n words Ξ
1, . . . , Ξ
n. What is the height of the resulting Trie?
Def: Height H
n= max{D
n(Ξ
i) : i = 1, . . . , n}.
The result P(D
n≤ k) = (1 − 2
−k)
n−1implies:
P (H
n> α log
2(n)) =
Consequence: P (H
n> α log
2(n)) → 0 for α > 2
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 9 / 19
Analysis The Height
Consider n words Ξ
1, . . . , Ξ
n. What is the height of the resulting Trie?
Def: Height H
n= max{D
n(Ξ
i) : i = 1, . . . , n}.
The result P(D
n≤ k) = (1 − 2
−k)
n−1implies:
P (H
n> α log
2(n)) = P (D
n(Ξ
i) > α log
2(n) for some i ∈ {1, . . . , n})
Consequence: P (H
n> α log
2(n)) → 0 for α > 2
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 9 / 19
Analysis The Height
Consider n words Ξ
1, . . . , Ξ
n. What is the height of the resulting Trie?
Def: Height H
n= max{D
n(Ξ
i) : i = 1, . . . , n}.
The result P(D
n≤ k) = (1 − 2
−k)
n−1implies:
P (H
n> α log
2(n)) = P (D
n(Ξ
i) > α log
2(n) for some i ∈ {1, . . . , n})
≤ n · P (D
n> α log
2(n))
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 9 / 19
Analysis The Height
Consider n words Ξ
1, . . . , Ξ
n. What is the height of the resulting Trie?
Def: Height H
n= max{D
n(Ξ
i) : i = 1, . . . , n}.
The result P(D
n≤ k) = (1 − 2
−k)
n−1implies:
P (H
n> α log
2(n)) = P (D
n(Ξ
i) > α log
2(n) for some i ∈ {1, . . . , n})
≤ n · P (D
n> α log
2(n))
≤ n · 1 − 1 − n
−αnKevin Leckey (Monash University) An Introduction to Tries 21.09.2015 9 / 19
Analysis The Height
Consider n words Ξ
1, . . . , Ξ
n. What is the height of the resulting Trie?
Def: Height H
n= max{D
n(Ξ
i) : i = 1, . . . , n}.
The result P(D
n≤ k) = (1 − 2
−k)
n−1implies:
P (H
n> α log
2(n)) = P (D
n(Ξ
i) > α log
2(n) for some i ∈ {1, . . . , n})
≤ n · P (D
n> α log
2(n))
≤ n · 1 − 1 − n
−αn≤ n
2−αKevin Leckey (Monash University) An Introduction to Tries 21.09.2015 9 / 19
Def: Height H
n= max{D
n(Ξ
i) : i = 1, . . . , n}.
The result P(D
n≤ k) = (1 − 2
−k)
n−1implies:
P (H
n> α log
2(n)) = P (D
n(Ξ
i) > α log
2(n) for some i ∈ {1, . . . , n})
≤ n · P (D
n> α log
2(n))
≤ n · 1 − 1 − n
−αn≤ n
2−αConsequence: P (H
n> α log
2(n)) → 0 for α > 2
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 9 / 19
Analysis The Height
Results on H
nPartly proven on the previous slide:
H
n2 log
2(n)
−→ 1
PE[H
n] ∼ 2 log
2(n) (n → ∞) (Flajolet, Steyaert ’82 → periodic second order term)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 10 / 19
Analysis The Height
Results on H
nPartly proven on the previous slide:
H
n2 log
2(n)
−→ 1
PThm (Devroye ’84):
n→∞
lim P(H
n− 2 log
2(n) − 1 ≤ x ) = exp(−2
−x), x ∈ R
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 10 / 19
H
n2 log
2(n)
−→ 1
PThm (Devroye ’84):
n→∞
lim P(H
n− 2 log
2(n) − 1 ≤ x ) = exp(−2
−x), x ∈ R Thm (Regnier ’82):
E[H
n] ∼ 2 log
2(n) (n → ∞) (Flajolet, Steyaert ’82 → periodic second order term)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 10 / 19
Analysis The Height
Summary: Typical depth: log
2(n), height: 2 log
2(n).
log2n + O(1)
2 log2n + O(1) 2 log2n + O(1)
(External nodes/Leaves) (Internal nodes)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 11 / 19
log2log nn + O(1)
log2n + O(1)
2 log2n + O(1)
log2log nn + O(1) log2n + O(1)
2 log2n + O(1)
(External nodes/Leaves) (Internal nodes)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 11 / 19
Analysis The External Path Length
Consider n words Ξ
1, . . . , Ξ
n. External Path Length:
L
n:=
n
X
i =1
D
n,i, D
n,i= D
n(Ξ
i).
Example: L
6= 2 + 3 + 4 · 4 = 21
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 12 / 19
Analysis The External Path Length
Consider n words Ξ
1, . . . , Ξ
n. External Path Length:
L
n:=
n
X
i =1
D
n,i, D
n,i= D
n(Ξ
i).
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 12 / 19
i =1
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
Example: L
6= 2 + 3 + 4 · 4 = 21
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 12 / 19
Analysis The External Path Length
A Recursion for L
nΞ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
K
n= # words starting with 0
L
n=
dKevin Leckey (Monash University) An Introduction to Tries 21.09.2015 13 / 19
Analysis The External Path Length
A Recursion for L
nΞ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
K
n= # words starting with 0
L
n=
dKevin Leckey (Monash University) An Introduction to Tries 21.09.2015 13 / 19
Analysis The External Path Length
A Recursion for L
nΞ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
K
n= # words starting with 0
L
n=
dKevin Leckey (Monash University) An Introduction to Tries 21.09.2015 13 / 19
Analysis The External Path Length
A Recursion for L
nΞ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
K
n= # words starting with 0
L
n=
dKevin Leckey (Monash University) An Introduction to Tries 21.09.2015 13 / 19
Analysis The External Path Length
A Recursion for L
nΞ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
K
n= # words starting with 0
L
n=
d LKnKevin Leckey (Monash University) An Introduction to Tries 21.09.2015 13 / 19
Analysis The External Path Length
A Recursion for L
nΞ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
K
n= # words starting with 0
L
n=
d LKn+
L˜n−KnKevin Leckey (Monash University) An Introduction to Tries 21.09.2015 13 / 19
Ξ4 Ξ2
Ξ3
Ξ1
Ξ6 Ξ5
K
n= # words starting with 0
L
n=
d LKn+
L˜n−Kn+ n
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 13 / 19
Analysis The External Path Length
The Contraction Method in a Nutshell
Aim: Find a limit law for L
n(after rescaling properly) L
n= L
d Kn+ ˜ L
n−Kn+ n
X =
d1
√
2 X + 1
√
2 X e (1)
3. Solution to (1): Existence of a solution to (1). Here: Normal distribution with mean 0.
4. Contraction: Find a metric such that (1) corresponds to the fixed point of a contracting map.
5. Convergence: Prove convergence with respect to that metric.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 14 / 19
Analysis The External Path Length
The Contraction Method in a Nutshell
Aim: Find a limit law for L
n(after rescaling properly) L
n= L
d Kn+ ˜ L
n−Kn+ n 1. Rescaling: X
n= (L
n− E[L
n])/pVar(L
n)
3. Solution to (1): Existence of a solution to (1). Here: Normal distribution with mean 0.
4. Contraction: Find a metric such that (1) corresponds to the fixed point of a contracting map.
5. Convergence: Prove convergence with respect to that metric.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 14 / 19
Analysis The External Path Length
The Contraction Method in a Nutshell
Aim: Find a limit law for L
n(after rescaling properly) L
n= L
d Kn+ ˜ L
n−Kn+ n 1. Rescaling: X
n= (L
n− E[L
n])/pVar(L
n)
X
n= A
d n,1X
Kn+ A
n,2X e
n−Kn+ b
ndistribution with mean 0.
4. Contraction: Find a metric such that (1) corresponds to the fixed point of a contracting map.
5. Convergence: Prove convergence with respect to that metric.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 14 / 19
Analysis The External Path Length
The Contraction Method in a Nutshell
Aim: Find a limit law for L
n(after rescaling properly) L
n= L
d Kn+ ˜ L
n−Kn+ n 1. Rescaling: X
n= (L
n− E[L
n])/pVar(L
n)
X
n= A
d n,1X
Kn+ A
n,2X e
n−Kn+ b
n2. Find the Limits: (A
n,1, A
n,2, b
n) −→ ???
point of a contracting map.
5. Convergence: Prove convergence with respect to that metric.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 14 / 19
Analysis The External Path Length
The Contraction Method in a Nutshell
Aim: Find a limit law for L
n(after rescaling properly) L
n= L
d Kn+ ˜ L
n−Kn+ n 1. Rescaling: X
n= (L
n− E[L
n])/pVar(L
n)
X
n= A
d n,1X
Kn+ A
n,2X e
n−Kn+ b
n2. Find the Limits: (A
n,1, A
n,2, b
n) −→ (( √
2)
−1, ( √
2)
−1, 0)
point of a contracting map.
5. Convergence: Prove convergence with respect to that metric.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 14 / 19
Analysis The External Path Length
The Contraction Method in a Nutshell
Aim: Find a limit law for L
n(after rescaling properly) L
n= L
d Kn+ ˜ L
n−Kn+ n 1. Rescaling: X
n= (L
n− E[L
n])/pVar(L
n)
X
n= A
d n,1X
Kn+ A
n,2X e
n−Kn+ b
n2. Find the Limits: (A
n,1, A
n,2, b
n) −→ (( √
2)
−1, ( √
2)
−1, 0) X =
d1
√
2 X + 1
√
2 X e (1)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 14 / 19
Analysis The External Path Length
The Contraction Method in a Nutshell
Aim: Find a limit law for L
n(after rescaling properly) L
n= L
d Kn+ ˜ L
n−Kn+ n 1. Rescaling: X
n= (L
n− E[L
n])/pVar(L
n)
X
n= A
d n,1X
Kn+ A
n,2X e
n−Kn+ b
n2. Find the Limits: (A
n,1, A
n,2, b
n) −→ (( √
2)
−1, ( √
2)
−1, 0) X =
d1
√
2 X + 1
√
2 X e (1)
3. Solution to (1): Existence of a solution to (1). Here: Normal distribution with mean 0.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 14 / 19
Analysis The External Path Length
The Contraction Method in a Nutshell
Aim: Find a limit law for L
n(after rescaling properly) L
n= L
d Kn+ ˜ L
n−Kn+ n 1. Rescaling: X
n= (L
n− E[L
n])/pVar(L
n)
X
n= A
d n,1X
Kn+ A
n,2X e
n−Kn+ b
n2. Find the Limits: (A
n,1, A
n,2, b
n) −→ (( √
2)
−1, ( √
2)
−1, 0) X =
d1
√
2 X + 1
√
2 X e (1)
3. Solution to (1): Existence of a solution to (1). Here: Normal distribution with mean 0.
4. Contraction: Find a metric such that (1) corresponds to the fixed point of a contracting map.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 14 / 19
L
n= L
Kn+ ˜ L
n−Kn+ n 1. Rescaling: X
n= (L
n− E[L
n])/pVar(L
n)
X
n= A
d n,1X
Kn+ A
n,2X e
n−Kn+ b
n2. Find the Limits: (A
n,1, A
n,2, b
n) −→ (( √
2)
−1, ( √
2)
−1, 0) X =
d1
√
2 X + 1
√
2 X e (1)
3. Solution to (1): Existence of a solution to (1). Here: Normal distribution with mean 0.
4. Contraction: Find a metric such that (1) corresponds to the fixed point of a contracting map.
5. Convergence: Prove convergence with respect to that metric.
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 14 / 19
Analysis The External Path Length
Results on L
nThm (Jacquet, Regnier ’88; Neininger, R¨ uschendorf 2004):
L
n− E[L
n] pVar(L
n)
−→ N (0, 1)
dFrom the analysis of D
n:
E[L
n] = E
"
nX
i =1
D
n(Ξ
i)
#
Thm (Kirschenhofer, Prodinger ’86):
Var(L
n) = n e Ψ(log
2(n)) + O(log
2(n))
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 15 / 19
Analysis The External Path Length
Results on L
nThm (Jacquet, Regnier ’88; Neininger, R¨ uschendorf 2004):
L
n− E[L
n] pVar(L
n)
−→ N (0, 1)
dFrom the analysis of D
n:
E[L
n] = E
"
nX
i =1
D
n(Ξ
i)
#
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 15 / 19
Analysis The External Path Length
Results on L
nThm (Jacquet, Regnier ’88; Neininger, R¨ uschendorf 2004):
L
n− E[L
n] pVar(L
n)
−→ N (0, 1)
dFrom the analysis of D
n:
E[L
n] = E
"
nX
i =1
D
n(Ξ
i)
#
= nE[D
n]
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 15 / 19
Analysis The External Path Length
Results on L
nThm (Jacquet, Regnier ’88; Neininger, R¨ uschendorf 2004):
L
n− E[L
n] pVar(L
n)
−→ N (0, 1)
dFrom the analysis of D
n:
E[L
n] = E
"
nX
i =1
D
n(Ξ
i)
#
= nE[D
n] = n log
2(n) + nΨ(log
2(n)) + o(n)
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 15 / 19
L
n− E[L
n] pVar(L
n)
−→ N (0, 1)
dFrom the analysis of D
n:
E[L
n] = E
"
nX
i =1
D
n(Ξ
i)
#
= nE[D
n] = n log
2(n) + nΨ(log
2(n)) + o(n)
Thm (Kirschenhofer, Prodinger ’86):
Var(L
n) = n e Ψ(log
2(n)) + O(log
2(n))
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 15 / 19
Summary
Trie:
tree-like data structure to store words
position of a word in the tree ↔ path given by shortest unique prefix Performance:
Consider input: n independent words, each word is a sequence of
’coin tosses’
Kevin Leckey (Monash University) An Introduction to Tries 21.09.2015 16 / 19