Presentation is loading. Please wait.

Presentation is loading. Please wait.

B-Trees.

Similar presentations


Presentation on theme: "B-Trees."— Presentation transcript:

1 B-Trees

2 Binary Trees Binary Trees spread data all over memory
Bad for layered memory (disk/ram/cache)

3 Disk Blocks Disk data stored in blocks/sectors
Accessed in blocks of 512bytes – 4kB

4 B Trees B Tree Each node can store up to n values
Pointer between each pair of values Max Degree = num pointers = n + 1

5 B Trees B Tree Node designed to fit block size May have degree of 100+
First level 100 keys Second level 100,000 keys Third level 100,000,000 keys! Still compare against keys one at a time

6 B Tree Simulation BTree Inserts Always insert at leaves
Split at max size, median value moves to parent Tree gets deeper when root splits

7 B Tree Simulation BTree Delete at Leaf: Remove from node Empty node
Steal from sibling via rotation if possible Else merge with sibling & steal key from parent Start Removed Removed 112

8 B Tree Simulation BTree Deletes At Internal Node Remove from node
Steal a replacement Leftmost from right child or Rightmost from left child If child underflows, merge Start Removed Removed 119


Download ppt "B-Trees."

Similar presentations


Ads by Google