Balanced Trees

(平衡木)

Data Structures and Algorithms

9th lecture, November 12, 2015

http://www.sw.it.aoyama.ac.jp/2015/DA/lecture9.html

Martin J. Dürst

AGU

© 2009-15 Martin J. Dürst 青山学院大学

Today's Schedule

 

Summary of Last Lecture

 

Strengthening or Weakening the Invariants of Binary Trees

 

Top-Down 2-3-4 Trees

 

Search in 2-3-4 Trees

(each operation on a 2-3-4 tree is a generalization of the same operation on a binary search tree)

 

Insertion into 2-3-4 Trees

Deletion from 2-3-4 Trees

 

Efficiency of 2-3-4 Trees

 

Implementation of 2-3-4 Tree

 

Red-Black-Trees

 

AVL-Trees

 

Secondary Storage

Internal Memory Secondary Storage
Access principle random random linear
Technology dynamic RAM HD, SSD magnetic tape
Unit of access word page record
Example unit size 32/64 bits (4/8 bytes) 512/1024/2048/4096/... bytes varying
Access speed nanoseconds milliseconds seconds or minutes

 

B-Trees

 

Page of a B-Tree

    ref. to subtree
key data
ref. to subtree
key data
ref. to subtree
... ...
...
key data
ref. to subtree
   

 

B+ Trees

Starting with a B-tree, all data (except keys) is moved to lowest layer of tree

⇒ The number of keys and child nodes per internal node increase
(for practical applications, the size of a key is much smaller than the size of the data)

⇒ The height of the tree shrinks

⇒ Access to data is faster

(the overall access time is dominated by the number of pages that have to be fetched from secondary memory)

 

Internal Page of a B+ Tree

  ref. to subtree
key
ref. to subtree
key
ref. to subtree
key
ref. to subtree
key
ref. to subtree
key
ref. to subtree
key
ref. to subtree
...
...
key
ref. to subtree
 

 

Leaf Page of a B+ Tree

key data
key data
key data
... ...
key data

 

Definition of Variables for B+ Trees

 

Items per Page for B+Trees

(⌊a⌋ is the floor function of a, the greatest integer smaller or equal to a)

 

Number of Nodes for B+Trees

(⌈a⌉ is the ceiling function of a, the smallest integer greater or equal to a)

 

Summary

 

Glossary

red-black-tree
赤黒木 (あかくろぎ)
AVL-tree
AVL 木
secondary storage
二次記憶装置
B-tree
B 木
B+ tree
B+木
strengthen
強化 (する)
weaken
緩和 (する)
uniform
一定 (の)
lowest layer
最下層
occupancy
占有率
floor function
床関数
ceiling function
天井関数
degree
次数