SDSU CS660 Combinatorial Algorithms
Fall Semester, 1996
Splay Performance

[To Lecture Notes Index]
San Diego State University -- This page last updated Nov 14, 1996
----------

Contents of Splay Performance

    1. Zipf's Law

Splay Performance Slide # 1

Zipf's Law


Zipf noticed that in English the frequency of word usage follows:

where fi denotes the frequency of the ith most frequent word


Zipfian Probability Distribution:

Assume we have a list of n items:

The a's are ordered by frequency of access

Probability of accessing item is and

Then

But so we have


Splay Performance Slide # 2
Zipfian Probability Distribution
Let for k = 1, 2, ..., n

where

Pk
n = 2
k12
Pk0.66670.3333

n = 3
k123
Pk0.54550.27270.1818

n = 4
k1234
Pk0.480.240.160.12

n = 5
k12345
Pk0.4380.2190.1460.1090.0876

n = 6
k123456
Pk0.4080.2040.1360.1020.0816.0680


Splay Performance Slide # 3
How to Implement Zipf's Distribution

Let
Method 1

If <= rand() < then return k
Method 2

For sample of size N
let item a1 be included N * P1 times
let item a2 be included N * P2 times


Splay Performance Slide # 4
Exp (?) Distribution

let


Splay Performance Slide # 5
Move-to-root vs. Splay Training

Insert integers 1 - Tree Size in random order

Same random order used to build each tree

Create a Zipfian sample of size "Sample"
Access each sample item in a tree

Each tree gets different sample
Tree Size 800Tree Size 1600
Sample 100Sample 200
SplayMtoRSplayMtoR
31185049
18413742
18174240
18193840
18183842
20183838
17173638
17173738
18173835
19153637
16173536
17143737
17173733
18163635
16153534
16163735
27163535
16163837
15163737
18153735


Splay Performance Slide # 6
Building Trees

Integers from 1 to N are inserted into a tree in random order

Each tree is created with the same random sequence

Times are in milliseconds
SizeBSTAVLSplayMoveToRoot
20017234552
40025349797
8005569222222
1600116146499490
320024630511361092
640053165024462406
128001155134053305196
25600261728351151911246


Splay Performance Slide # 7
Accessing Nodes in a Tree

In a tree of size N, accessed N keys

Keys to access were selected according to a distribution of keys in tree

Keys access were in random order

In each tree used the same keys in the same order
Exp Distribution
SizeBSTAVLSplayMoveToRoot
2009598
40022111816
80030253532
160064556861
3200168122135122
6400422264260254
12800707489512467
25600155512401029979

Zipf Distribution
SizeBSTAVLSplayMoveToRoot
200752828
40014126964
8003024148140
16006960326318
3200141120697682
640034426515211482
1280071361833413213
256001676125171976972


----------