180 200 156 179 120 130 101 110
- Slides: 15
180 200 156 179 120 130 101 110 30 35 3 5 11 120 150 180 30 100 B+Tree Example n=3 Root 1
B+ tree in textbook’s notation n=3 30 35 Leaf: 30 30 Non-leaf: 30 35 2
Size of nodes: n+1 pointers n keys (fixed) 3
Don’t want nodes to be too empty • Use at least Non-leaf: (n+1)/2 pointers Leaf: (n+1)/2 pointers to data 4
B+tree rules tree of order n (1) All leaves at same lowest level (balanced tree) (2) Pointers in leaves point to records except for “sequence pointer” (to next leaf) 5
(3) Number of pointers/keys for B+tree Max Min ptrs keys ptrs data Non-leaf (non-root) Leaf (non-root) Root Min keys n+1 n (n+1)/2 - 1 n+1 n (n+1)/2 n+1 n 1 1 6
Insert into B+tree (a) simple case (insert 32) – space available in leaf (b) leaf overflow (insert 7) (c) non-leaf overflow (insert 160) (d) new root (insert 45) 7
Deletion from B+tree (a) Simple case - no example (b) Coalesce with neighbor (delete 50) (c) Re-distribute keys (delete 50) (d) Cases (b) or (c) at non-leaf (delete 37) 8
B+tree deletions in practice – Often, coalescing is not implemented – Too hard and not worth it! 9
Variation on B+tree: B-tree (no +) • Idea: – Avoid duplicate keys (leaf and non-leaf) – Have record pointers in non-leaf nodes 10
K 1 P 1 to keys < K 1 K 2 P 2 K 3 P 3 to record with K 1 with K 2 with K 3 to keys K 1<x<K 2 K 2<x<k 3 to keys >k 3 11
170 180 150 160 130 140 110 120 90 100 70 80 50 60 30 40 10 20 145 165 85 105 25 45 65 125 B-tree example n=2 12
170 180 150 160 145 165 110 120 90 100 70 80 50 60 30 40 10 20 25 45 85 105 (but keep space for simplicity) 130 140 • sequence pointers not useful now! n=2 65 125 B-tree example 13
Note on inserts leaf 10 20 30 • Say we insert record with key = 25 n=3 14
Note on inserts • Say we insert record with key = 25 25 30 10 – 20 – • Afterwards: 10 20 30 leaf n=3 15
- 100+200+200
- 000 111 000
- Où se trouve le numéro d'affiliation mutuelle vignette ?
- If , what is ? 20° 70° 110° 130°
- 100+120+140+160+180
- 101 102 103 104 105 106 107 108
- 1 10 11 100 101 110 111 1000 1001 1010
- 120px x 120px
- 120/100*80
- 49 un yüzde 40'ı kaçtır
- 120factors
- 200+160+120
- The partial pressure of oxygen was observed to be 156 torr
- Ley 24 156
- Factors of 156
- 98 156 chia 4 63