SDSU CS 660: Combinatorial Algorithms
Tree Performance

[To Lecture Notes Index]
San Diego State University -- This page last updated October 31, 1995
----------

Contents of Tree Performance Lecture

  1. References
  2. Performance
    1. Baer and Schwab Tests
      1. Implementation-Independent Measures
      2. Time Results

References

Handbook of Algorithms and Data Structures, by G. H. Gonnet

A Comparison of Tree-Balancing Algorithms, Baer and Schwab, CACM, V 20, Num 5, May 1977, pp 322-330

Performance


n = number of nodes in the tree
C(n) = average number of comparisons to find a key
E[ h(n) ] = expected height of tree
R(n) = average number of rotations per insertion/deletion
Simulation Results Binary Search TreesRandom Input
nC(n)E[ h(n) ]
52.483.8
103.4445.6
506.17810.810
1007.47913.286
50010.61319.336
100011.98622.036
500015.19328.428
1000016.57731.222
Simulation Results AVL
nC(n)E[ h(n) ]R(n)
52.23.00.213
102.9074.00.318
504.9306.9470.427
1005.8897.9990.444
5008.19210.9230.461
10009.20211.9980.463
500011.55514.9360.465
1000012.56815.9960.465
Simulation Results BB[ 1 - ] trees
nC(n)E[ h(n) ]R(n)
52.23.00.213
102.94.00.326
504.9447.0260.409
1005.9088.2080.422
5008.23111.2610.432
10009.24512.5880.433
500011.61815.6530.435
1000012.65017.0000.434

Baer and Schwab Tests

Algorithms

AVL
BB[ 1 - ]
COM - complete restructuring of tree
Input

N = 1000

R = random input

W = worst case
1, 1000, 2, 999, 3, ...
Hardware

CDC 6400

Implementation-Independent Measures

Random input
TreeMax LevelAve path Av insert. Rotations
lengthpath
Random22.612.1412.140
AVL12.9.209.73461
BB12.69.269.70426
COM11.89.069.6812.8
Worst Case input
TreeMax LevelAve path Av insert. Rotations
lengthpath
Random1000500.5500.50
AVL129.2711.51988
BB139.3612.321041
COM309.2018.1174

Time Results

Random AVL BB 1 - BB .25 BB .15 COM
TreeRandomWorst Case
0.58>10
0.961.06
2.202.84
2.363.68
2.325.34
0.933.61

Questions Addressed

Assuming that most trees are random, what is the ratio of the number of insertions to the number of subsequent queries which make a balancing worthwhile?
	AVL Tree	3 queries per insertion

	BB Tree	10 queries per insertion


What is the best algorithm?
	AVL