Balanced Trees

(平衡木)

Data Structures and Algorithms

9th lecture, November 28, 2017

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

Martin J. Dürst

AGU

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

Today's Schedule

 

Leftovers

 

Summary of Last Lecture

 

Strengthening or Weakening Invariants of Binary Trees

 

Top-Down 2-3-4 Trees

 

Search in 2-3-4 Trees

 

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 External (Secondary) Storage
Access principle random random linear
Technology dynamic RAM SSD, HD magnetic tape
Unit of access word page/sector record
Example unit size 32/64 bits (4/8 bytes) 512/1024/2048/4096/... bytes varying
Access speed nanoseconds micro/milliseconds seconds or minutes

 

B-Trees

 

Page of a B-Tree

diagram of a B-Tree

 

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

diagram of an internal page of a B+ Tree

 

Leaf Page of a B+ Tree

diagram of a leaf page of a B+ Tree

 

Definition of Variables for B+ Trees

 

Items per Page for B+Trees

(⌊a⌋ is the floor function of a, the greatest integer smaller than or equal to a,
a⌋∈ℤ ∧ ⌊a⌋≦a ∧ ¬∃b: b∈ℤ ∧ ⌊a⌋≦b<a)

 

Number of Nodes for B+Trees

(⌈a⌉ is the ceiling function of a, the smallest integer greater than or equal to a,
a⌉∈ℤ ∧ a≦⌈a⌉ ∧ ¬∃b: b∈ℤ ∧ a<b≦⌈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
次数