Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented...

90
Digital search trees Analysis of different digital trees with Rice’s integrals. JASS Nicolai v. Hoyningen-Huene 28.3.2004 28.3.2004 JASS 04 - Digital search trees 1

Transcript of Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented...

Page 1: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Digital search trees

Analysis of different digital trees with Rice’s integrals.

JASS

Nicolai v. Hoyningen-Huene

28.3.2004

28.3.2004 JASS 04 - Digital search trees 1

Page 2: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree:

• Definition

• Average case analysis

➮ Tries:

• Definition

• Average case analysis

➮ General framework

28.3.2004 JASS 04 - Digital search trees 2

Page 3: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➠ Tree

➮ Digital search tree

➮ Tries

➮ General framework

28.3.2004 JASS 04 - Digital search trees 3

Page 4: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Tree

28.3.2004 JASS 04 - Digital search trees 4

Page 5: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Tree

Definition 0.1 A tree is defined in several ways:

1. A connected, undirected, acyclic graph. It is rooted and ordered

unless otherwise specified.

2. A data structure accessed beginning at the root node. Each node

is either a leaf or an internal node. An internal node has one or

more child nodes and is called the parent of its child nodes. All

children of the same node are siblings.

3. A tree is either empty (no nodes), or a root and zero or more

subtrees. The subtrees are ordered.

28.3.2004 JASS 04 - Digital search trees 5

Page 6: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Search tree

28.3.2004 JASS 04 - Digital search trees 6

Page 7: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➠ Digital search tree:

• Definition

• Average case analysis

➮ Tries

➮ General framework

28.3.2004 JASS 04 - Digital search trees 7

Page 8: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree:

➠ Definition

• Average case analysis

➮ Tries

➮ General framework

28.3.2004 JASS 04 - Digital search trees 8

Page 9: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Digital search tree

28.3.2004 JASS 04 - Digital search trees 9

Page 10: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Digital search tree

A digital search tree is a dictionary implemented as a digital tree

which stores strings in internal nodes, so there is no need for extra

leaf nodes to store the strings.

28.3.2004 JASS 04 - Digital search trees 10

Page 11: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree:

• Definition

➠ Average case analysis:– Internal path length

– External internal nodes

➮ Tries

➮ General framework

28.3.2004 JASS 04 - Digital search trees 11

Page 12: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree:

• Definition

• Average case analysis:

➠ Internal path length– External internal nodes

➮ Tries

➮ General framework

28.3.2004 JASS 04 - Digital search trees 12

Page 13: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

The internal path length of a tree is the sum of the depth of every

node of the tree.

28.3.2004 JASS 04 - Digital search trees 13

Page 14: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Fundamental recurrence relation

AN = N−1+∞∑

k=0

1

2N−1

(N − 1

k

)(Ak + AN−1−k) , N ≥ 1

with A0 := 0.

28.3.2004 JASS 04 - Digital search trees 14

Page 15: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Transformation

∞∑N=1

ANzN−1

(N − 1)!= zez + 2

∞∑

k=0

Ak

k!

(z

2

)k

ez2

A′ (z) = zez + 2A(z

2

)e

z2

28.3.2004 JASS 04 - Digital search trees 15

Page 16: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Substitution by B(z)

A (z) = ezB (z) =

( ∞∑N=0

zN

N !

)( ∞∑N=0

BNzN

N !

)

AN =N∑

k=0

(N

k

)Bk

28.3.2004 JASS 04 - Digital search trees 16

Page 17: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Substitution by B(z)

A′ (z) = zez + 2A(z

2

)e

z2

B′ (z) + B (z) = z + 2B(z

2

)

BN + BN−1 =1

2N−2BN−1

28.3.2004 JASS 04 - Digital search trees 17

Page 18: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Substitution by B(z)

BN = (−1)NN−2∏j=1

(1− 1

2j

)

28.3.2004 JASS 04 - Digital search trees 18

Page 19: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Introduction of QN

QN =N∏

j=1

(1− 1

2j

)

28.3.2004 JASS 04 - Digital search trees 19

Page 20: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Introduction of Q(x)

Q (x) =∞∏

j=1

(1− x

2j

)

Q (1) = Q∞

28.3.2004 JASS 04 - Digital search trees 20

Page 21: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Q(x) is used for a meromorphic function of QN

QN =Q (1)

Q (2−N)

28.3.2004 JASS 04 - Digital search trees 21

Page 22: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

The function Q(x)

–4

–2

0

2

4

y

–10 –8 –6 –4 –2 2 4 6 8 10x

28.3.2004 JASS 04 - Digital search trees 22

Page 23: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Explicit formula for AN

AN =N∑

k=2

(N

k

)(−1)k Q (1)

Q (2−k+2)

28.3.2004 JASS 04 - Digital search trees 23

Page 24: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Rice’s method

N∑

k=0

(N

k

)(−1)k f (k) = − 1

2πi

C

B (N + 1,−z) f (z) dz

28.3.2004 JASS 04 - Digital search trees 24

Page 25: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Application of Rice’s method

AN = − 1

2πi

C

B (N + 1,−z)Q (1)

Q (2−z+2)dz

28.3.2004 JASS 04 - Digital search trees 25

Page 26: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Beta-Function

B (p, q) =Γ (p) Γ (q)

Γ (p + q)

28.3.2004 JASS 04 - Digital search trees 26

Page 27: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Beta-Function

–1e+11

–5e+10

5e+10

1e+11

–10 10 20 30 40z

28.3.2004 JASS 04 - Digital search trees 27

Page 28: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Gamma-Function

–10

–8

–6

–4

–20

2

4

6

8

10

y

–4 –2 2 4z

28.3.2004 JASS 04 - Digital search trees 28

Page 29: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Cauchy’s theorem

If f(z) is analytic in C except final number of poles a1, a2, ..., an

inside C, then

1

2πi

C

f (z) dz =n∑

k=1

Resz=akf (z)

28.3.2004 JASS 04 - Digital search trees 29

Page 30: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Approximation with Rectangle RXY with (12 ± iY,X ± iY )

AN = − 1

2πi

RXY

B (N + 1,−z)Q (1)

Q (2−z+2)dz −ResRXY /C

28.3.2004 JASS 04 - Digital search trees 30

Page 31: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Approximation of the integral

1

2πi

RXY

B (N + 1,−z)Q (1)

Q (2−z+2)dz =

O

(∫ Y

−Y

Γ (N + 1)

Γ(N + 1

2− iy

)dy

)= O

(∫ Y

−Y

N12−iydy

)= O

(N

12

)

28.3.2004 JASS 04 - Digital search trees 31

Page 32: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Residue at z = 1

−B (N + 1,−z) = − N

z − 1−N (HN−1 − 1) + O (z − 1)

HN−1 = γ + ln N −O

(1

N

)

−B (N + 1,−z) = − N

z − 1−N (γ + ln N − 1) + O (z − 1)

28.3.2004 JASS 04 - Digital search trees 32

Page 33: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Residue at z = 1

Q (1)

Q (2−z+1)= 1− α ln 2 (z − 1) + O

((z − 1)2)

28.3.2004 JASS 04 - Digital search trees 33

Page 34: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Residue at z = 1

1

1− 2−z+1=

1

1− eln 2(−z+1)

= − 1

(−z + 1) ln 2+

1

2− −z + 1

12+ O

((−z + 1)3)

=1

(z − 1) ln 2+

1

2+ O (z − 1)

28.3.2004 JASS 04 - Digital search trees 34

Page 35: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Residue at z = 1

∆z=1 = −N lg N −N

(γ − 1

ln 2− α +

1

2

)+ O (1)

28.3.2004 JASS 04 - Digital search trees 35

Page 36: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Residues at z = j ± 2πikln 2 for Q(2−z+j)

∆z=1± 2πIkln 2

= −Nδ (N) + O (1)

where

δ (N) =1

ln 2

k 6=0

Γ

(−1− 2πik

ln 2

)e2πik lg N

28.3.2004 JASS 04 - Digital search trees 36

Page 37: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Internal path length

Average case

AN = N lg N + N

(γ − 1

ln 2− α +

1

2+ δ (N)

)+ O

(N

12

)

28.3.2004 JASS 04 - Digital search trees 37

Page 38: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree:

• Definition

• Average case analysis:– Internal path length

➠ External internal nodes– Multiway branching

➮ Tries

➮ General framework

28.3.2004 JASS 04 - Digital search trees 38

Page 39: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodesDefinition

External internal nodes are nodes with both links null.

28.3.2004 JASS 04 - Digital search trees 39

Page 40: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodesFundamental recurrence relation

CN =∞∑

k=0

1

2N−1

(N − 1

k

)(Ck + CN−1−k) , N ≥ 2

with C1 = 1 and C0 = 0.

28.3.2004 JASS 04 - Digital search trees 40

Page 41: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodesTransformation

C (z) =∞∑

N=0

CNzN

N !

C ′ (z) = 1 + 2C(z

2

)e

z2

28.3.2004 JASS 04 - Digital search trees 41

Page 42: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

Substitution by D (z) = e−zC (z)

D (z) =∞∑

N=0

DNzN

N !

D′ (z) + D (z) = e−z + 2D(z

2

)

28.3.2004 JASS 04 - Digital search trees 42

Page 43: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

Recurrence for DN

DN + DN−1 = (−1)N−1 +1

2N−2DN−1

DN = (−1)N−1 −(

1− 1

2N−2

)DN−1, N ≥ 2

with D1 = 1 and D0 = 0

28.3.2004 JASS 04 - Digital search trees 43

Page 44: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

Introduction of RN

RN = QN

(1 +

N∑

k=1

1

Qk

)

28.3.2004 JASS 04 - Digital search trees 44

Page 45: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

Explicit formula for CN

CN = N −∞∑

k=2

(N

k

)(−1)k Rk−2

28.3.2004 JASS 04 - Digital search trees 45

Page 46: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

Simpler coefficients R∗N

R∗N =

(N + 1− α) qN+1

1− qN+1+

1

1− qN+1R∗

N+1

28.3.2004 JASS 04 - Digital search trees 46

Page 47: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

The meromorphic function R∗ (z)

R∗ (z) =∞∑i=2

(z + 1 + i− α) qz+1+i

∏ij=0 (1− qz+1+j)

28.3.2004 JASS 04 - Digital search trees 47

Page 48: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

The meromorphic function R∗ (z)

–4

–2

0

2

4

y

–10 –8 –6 –4 –2 2 4 6 8 10z

28.3.2004 JASS 04 - Digital search trees 48

Page 49: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

Explicit formula for CN

CN = (N − 1) (α + 1)−∞∑

k=2

(N

k

)(−1)k R∗

k−2

28.3.2004 JASS 04 - Digital search trees 49

Page 50: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodesApplying Rice’s method

CN − (N − 1) (α + 1) =1

2πi

C

B (N + 1,−z) R∗ (z − 2) dz

28.3.2004 JASS 04 - Digital search trees 50

Page 51: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

Approximation with Rectangle RXY

CN−(N − 1) (α + 1) =1

2πi

RXY

B (N + 1,−z) R∗ (z − 2) dz−∆R

28.3.2004 JASS 04 - Digital search trees 51

Page 52: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodesApproximation of the integral

O

(∫ Y

−Y

Γ (N + 1)

Γ(N + 1

2− iy

)dy

)= O

(∫ Y

−Y

N12−iydy

)= O

(N

12

)

28.3.2004 JASS 04 - Digital search trees 52

Page 53: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

Residue at z = 1

∆z=1 = N

(β + 1− 1

Q∞

(α2 − α− 1

ln q

))

28.3.2004 JASS 04 - Digital search trees 53

Page 54: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes

Residues at z = −1± 2πikln q

δ∗ (N) =2πik

Q∞ ln q

k 6=0

1

ln qΓ

(−1− 2πik

ln q

)e2πik lg N

28.3.2004 JASS 04 - Digital search trees 54

Page 55: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodesAverage case

CN = N

(β + 1− 1

Q∞

(1

ln 2+ α2 − α

)+ δ∗ (N)

)+O

(N

12

)

28.3.2004 JASS 04 - Digital search trees 55

Page 56: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree:

• Definition

• Average case analysis:– Internal path length

– External internal nodes

➠ Multiway branching

➮ Tries

➮ General framework

28.3.2004 JASS 04 - Digital search trees 56

Page 57: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Multiway branching

Fundamental recurrence relation for external nodes

C[M ]N =

k1+k2+...+kM=N−1

1

MN−1

(N − 1

k1, k2, ..., kM

) (M∑i=1

C[M ]ki

)

with C[M ]1 = 1 and C

[M ]0 = 0

28.3.2004 JASS 04 - Digital search trees 57

Page 58: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Multiway branching

Fundamental recurrence relation for external nodes

C[M ]N = M

k1+k2+...+kM=N−1

1

MN−1

(N − 1

k1, k2, ..., kM

)C

[M ]k1

with C[M ]1 = 1 and C

[M ]0 = 0

28.3.2004 JASS 04 - Digital search trees 58

Page 59: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Multiway branching

Transformation

C [M ] (z) =∞∑

N=0

C[M ]N zN

N !

C [M ]′ (z) = 1 + MC [M ]( z

M

)(e(1− 1

M )z)

28.3.2004 JASS 04 - Digital search trees 59

Page 60: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Multiway branching

average case for external nodes

C[M ]N = N

(β[M ] + 1− 1

Q[M ]∞

(1

ln M+ α[M ]2 − α[M ]

))

+Nδ[M ] (N)

+O(N

12

)

28.3.2004 JASS 04 - Digital search trees 60

Page 61: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree

➠ Tries

• Defintions

• Average case analysis

➮ General framework

28.3.2004 JASS 04 - Digital search trees 61

Page 62: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree

➮ Tries:

➠ Defintion of– Digital search trie

– Patricia trie

• Average case analysis

➮ General framework

28.3.2004 JASS 04 - Digital search trees 62

Page 63: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Digital search trie

A digital search trie is a digital tree for storing a set of strings in

which there is one node for every prefix of every string in the set.

28.3.2004 JASS 04 - Digital search trees 63

Page 64: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Patricia trie

A Patricia tree is defined as a compact representation of a digital

search trie where all nodes with one child are merged with their

parent.

28.3.2004 JASS 04 - Digital search trees 64

Page 65: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree:

➮ Tries:

• Defintions

➠ Average case analysis:– External path length

– External internal nodes

➮ General framework

28.3.2004 JASS 04 - Digital search trees 65

Page 66: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree

➮ Tries:

• Defintions

• Average case analysis:

➠ External path length– External internal nodes

➮ General framework

28.3.2004 JASS 04 - Digital search trees 66

Page 67: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External path length for digital search trie

Fundamental recurrence relation

A[T ]N = N +

∞∑

k=0

1

2N

(N

k

) (A

[T ]k + A

[T ]N−k

), N ≥ 2

with A[T ]0 = A

[T ]1 = 0

28.3.2004 JASS 04 - Digital search trees 67

Page 68: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External path length for digital search trie

Transformation

A[T ] (z) = z (ez − 1) + 2A[T ](z

2

)ez−2

28.3.2004 JASS 04 - Digital search trees 68

Page 69: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External path length for digital search trie

Substitution by B (z)

A (z) = ezB (z)

B[T ] (z) = z(1− e−z

)+ 2B[T ]

(z

2

)

28.3.2004 JASS 04 - Digital search trees 69

Page 70: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External path length for digital search trie

Explicit formula

B[T ] (z) =N (−1)N

1− (12

)N−1

A[T ]N =

∞∑

k=2

(N

k

)k (−1)k

1− (12

)k−1

28.3.2004 JASS 04 - Digital search trees 70

Page 71: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External path length for digital search trie

average case

A[T ]N = N lg N + N

ln 2+

1

2+ δ (N)

)+ O(1)

28.3.2004 JASS 04 - Digital search trees 71

Page 72: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External path length for Patricia trie

Fundamental recurrence relation

A[P ]N = N

(1− 1

2N−1

)+

∞∑

k=0

1

2N

(N

k

) (A

[P ]k + A

[P ]N−k

), N ≥ 1

28.3.2004 JASS 04 - Digital search trees 72

Page 73: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External path length for Patricia trie

Transformation

A[P ] (z) = z(ez − e

z2

)+ 2A[P ]

(z

2

)e

z2

28.3.2004 JASS 04 - Digital search trees 73

Page 74: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External path length for Patricia trie

Substitution

B[P ] (z) = z(1− e−

z2

)+ 2B[P ]

(z

2

)

B[P ] (z) =N (−1)N

2N−1 − 1

28.3.2004 JASS 04 - Digital search trees 74

Page 75: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External path length for Patricia trie

Explicit formula

A[P ]N =

∞∑

k=2

(N

k

)k (−1)k

2k−1 − 1= A

[T ]N −N

28.3.2004 JASS 04 - Digital search trees 75

Page 76: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree

➮ Tries:

• Defintions

• Average case analysis:– External path length

➠ External internal nodes

➮ General framework

28.3.2004 JASS 04 - Digital search trees 76

Page 77: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes for Patricia trieFundamental recurrence relation

C[P ]N =

∑ 1

2N

(N

k

) (C

[P ]k + C

[P ]N−k

), N ≥ 3

with C[P ]0 = C

[P ]1 = 0 and C

[P ]2 = 1

28.3.2004 JASS 04 - Digital search trees 77

Page 78: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes for Patricia trieTransformation

C [P ] (z) =(z

2

)2

+ 2C [P ](z

2

)e

z2

28.3.2004 JASS 04 - Digital search trees 78

Page 79: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes for Patricia trieSubstitution

D[P ] (z) =(z

2

)2

e−z + 2D[P ](z

2

)

28.3.2004 JASS 04 - Digital search trees 79

Page 80: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes for Patricia trieExplicit formula

C[P ]N =

1

4

N∑

k=2

(N

k

)k (k − 1) (−1)k

1− 12

k−1

28.3.2004 JASS 04 - Digital search trees 80

Page 81: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

External internal nodes for Patricia trieaverage case

C[P ]N = N

(1

4 ln 2+ δ

[P ](N)

)

28.3.2004 JASS 04 - Digital search trees 81

Page 82: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

content

➮ Tree

➮ Digital search tree

➮ Trie

➠ General framework

28.3.2004 JASS 04 - Digital search trees 82

Page 83: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

General Framework for digital search trees

Fundamental recurrence relation

X (T ) =∑

subtrees Tj of the root of T

X (Tj) + x (T )

28.3.2004 JASS 04 - Digital search trees 83

Page 84: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

General Framework for digital search trees

Transformation

X (z) =∞∑

N=0

XNzN

N !

X ′ (z) = MX( z

M

)e(1− 1

M )z + x (z)

28.3.2004 JASS 04 - Digital search trees 84

Page 85: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

General Framework for digital search trees

Substitution

Y (z) = e−zX (z)

y (z) = e−zx (z)

Y ′ (z) + Y (z) = MY( z

M

)+ y′ (z) + y (z)

28.3.2004 JASS 04 - Digital search trees 85

Page 86: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

General Framework for digital search trees

Explicit formula

XN =N∑

k=0

(N

k

)Yk

28.3.2004 JASS 04 - Digital search trees 86

Page 87: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

General Framework for digital search trees

Asymptotic analysis of (−1)k Yk

Find a function Y ∗k which

(i) is simply related to Yk so that∑N

k=0

(Nk

) (Yk − (−1)k Y ∗

k

)is

easily evaluated,

(ii) satisfies a recurrence of the form

Y ∗N+1 = (1− g (M, N)) Y ∗

N + f (M,N),

(iii) goes to zero quickly as N →∞.

28.3.2004 JASS 04 - Digital search trees 87

Page 88: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

General Framework for digital search trees

Asymptotic analysis of (−1)k Yk

Turn the recurrence around to extend Y ∗N to the complex plane.

Evaluate∑N

k=0

(Nk

) (Yk − (−1)k Y ∗

k

)as detailed in the previous

sections.

28.3.2004 JASS 04 - Digital search trees 88

Page 89: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

General Framework for tries

X (T ) =∑

subtrees Tj of the root of T

X (Tj) + x (T )

X (z) = MX( z

M

)e

zM + x (z)

This can be solved by Rice’s method or also by Mellin transform

techniques.

28.3.2004 JASS 04 - Digital search trees 89

Page 90: Digital search trees - TUM · Digital search tree A digital search tree is a dictionary implemented as a digital tree which stores strings in internal nodes, so there is no need for

Thank you for your attention!

28.3.2004 JASS 04 - Digital search trees 90