b t
play

B-T Inverters : Bayer ' ? McCreight , 1970 Boeing Research Labs . - - PowerPoint PPT Presentation

B-T Inverters : Bayer ' ? McCreight , 1970 Boeing Research Labs . - tree ? why B- ? ? Bayer , Boeing , Broad , Bushy , . . . . . . . the more you think about what " McCreight , 2014 means , the better you understand the Bin B- trees B-


  1. B-T

  2. Inverters : Bayer ' ? McCreight , 1970 Boeing Research Labs . - tree ? why B- ? ? Bayer , Boeing , Broad , Bushy , . . . . . . . the more you think about what " McCreight , 2014 means , the better you understand the Bin B- trees B- trees . " was initially rejected ) ( The paper introducing them

  3. ⇐ m-arysearchtree.sn rooted trees where • each node may have up to m children K children has k -1 keys . • a node with a natural generalization of BST search : • search is ' Exi An order - 5 ( 5- ar y ) search tree . search for 8\h A 779 262 727 L 97 < 27 179 , 62 - Search is a generalization of BST search - Generalization of in - order traversal visits keys in order - I

  4. Order m B- Tree ( As per textbook ) 5- tree , * " m - ar - data Items stored at leaves , keys in other nudes guide search - non - leaf nodes , other than the root have between TM1N and m children is a leaf M children , or • the root has between 2 and ith key non - heat is the smallest • in a node , the key stored in the Itt " subtree same depth - all leaves are at the L keys ( for fixed L ) . leaves contain between Mil and some L are fewer than THE ( unless there . . ) . tree keys in the * in this version of B- tree , not an m - ary search tree as defined on slide . previous

  5. B- Tree Search : Generalization of BST search . - Example , in an order -5 B- tree :( This tree : order 75 because of • must have * because of D.) be of order 56 • must not Find 49 :\ µ ③ ⑤ " 3

  6. sieetetteightofttperfecttrees-Aperfeetm-arytree-isanm.ae ry tree where : - every node has Zero m children or depth leaf has the same - every - A perfect m - ary tree of height h has the max # of a height - h m - ary tree nodes for . The number of nodes in a perfect m - airy tree of Fact : - height h is : mh m - I a perfect binary tree The number of nodes in for : - 2h11 of height h is .

  7. The number of nodes at depth d. in a perfect ' of height at 2d binary tree least d is - Proof By induction on d 2d -20=1 Basis : D= 0 . an assume that ' 70 I. It . Choose some d is 2d nodes at depth d the number of Is . We must show that the number of nodes is 2d ? at depth dH • a perfect binary tree since the tree ✓ ↳ is & of height > dtl , every node at depth d 2 children . : has d- nodes at depth dtt a , the number of o/\o So dtt = 2dt¥ is g. 2d

  8. in a perfect m - ary nodes at depth d The number of is md tree of height at least d . PI By induction on depth d- , and md=m° is just the root = I There Basis : D= 0 . assume the some d > 0 and Choose III. : number of nodes at depth d md is . : We must show that the number of nodes at II. is mdtt depth dtl . a perfect m - ary tree of Since the tree is height node at at least dtt every , depth d has m children . , the number of nodes at depth dtl So is = mdtl µ - Md M

  9. ⇒ Claim : Every - m B- tree of height h contains order least (E) h at keys . P¥ Observe that every m - ary B- tree of height - graph has a perfect (f) - cry tree as sub : h a " has (E) " leaves so the B- tree This " subtree , does also . least hz keys , Since each leaf has at contains at least CH2X math key the B- tree 5.

  10. 1¥ : The height of B- tree with an order - m = 0 ( log n ) log m=n at most keys is n Let T be an order m B- tree with If : n nodes We have : ¥ )h - and height h . ± n n ) log ; n =0( log So h E ⇐ Searching for a key in a B- tree with can be done in time 0( log n ) n keys .

  11. B-treeinserti.org/L=m-- 5) ① Insert 57 7 ¥ *

  12. After inserting 57 : . go [ This leaf will be " overfull " Now , insert 5 =D we spH ÷ :÷÷÷:¥i ⇒ .

  13. After insertion of 554 splitting of leaf :

  14. splittinganInternalhlodet-ns.at 407 ← . g ④ F%¥¥ * splitting the leaf ¥ " ¥ :

  15. Afterspliking 0

  16. splittingtheRoot.orerfullroyt.j.IT/.y?Newroot . 11111 × 117 EE THI THI I b. b. ¥ , I k 1 b. b. x. A . . Tree just got taller same ( larger ) depth have the . Still , leaves all .

  17. BTreeInsertij new key k belongs , call it Find the leaf where v. a insert K into v ) { while ( v over - full and not the root is split v. i v ← parent G) ¥ r over - full is the root and . split in two , v new root with two children . add a time • Claim : B - tree insertion can be done in n is the number of 0 ( log n ) , where keys in the tree .

  18. I B-treeRemov L with the key K . Find the leaf to be removed - delete K from L K was the smallest key in L , correct the key in an ancestor - if - V ← L is not root ) { has too few keys - ( r and = while if ( v has an adjacent sibling u with more than MK7 children ) l a key and child from it to v. shift } else { of r v with a sibling merge u ← parent of the merged node } } is root and has only if I v one child , c ) new root . c is the delete vj ( corrected . )

  19. ⇒ Ifkwasthesmadestheafinl.ir ① , '

  20. If node v has too few keys not root . . and is . - an adjacent sibling v with sometimes can metre , we 1- ' ¥R i¥¥ ⇒ A n ADD A D B A • A - sometimes not r with a 1- merging H¥ I \ sibling makes 1 ✓ I 5¥ D; f I that is a node Overfull

  21. ↳ fEff ⇒ ) I 'T remove 79 =D → in : ¥ it .sn . y " extra " means / a key ( 76 ) ④ shift more than the + . min . T t t Et : ( corrected )

  22. tIingunderfuHnod : • shifting is cheaper than merging , parent under - full and never leaves the . fix by shifting if possible ⇐ ⑤ ' . ( both adjacent not possible . if min . # keys ) have siblings , then fix by merging .

  23. tixinfuging.GL?fym=5 ) 52 remove 12614116¥ to ← → I ← HH TITHE * b I I t b am p I too small merge with sibling ¢ d- → * m %

  24. ↳ shiftingataninternaluodlnas.IE :b " too few to 1 ↳ ← A T¥ . shift a key + child . ¥71 → 4 I µ . aissi rotation ) ✓ e Hn * * i. 1¥ tool *

  25. whenamergeshrinksaninterndnode-T.IE ← ↳ ← just too got small I because of a ADD A A deletion T5 T4 T3 The T1 $ merge Y 9- I l I 1 I / A DAD D T5 T3 T4 T2 TI

  26. whentherootgetstoosmali.FI ← ↳ Fol ← just too T got small / IT 1 . I 17PM 17 17 $ merge IBE Tree height ④ so¥ reduced is ' ' 1 1 by I / .

  27. LOmparisonof2logznandlogmk.lv us B- Tree . orst case height of Avhtree example m= 1024 , for a concrete - We choose . Logan Rogen R -10 - I 7 I 13 100 I 1000 20 104 2 27 106 40 2 108 53 3 10 " 66 4 10 " 80 5 = logz × %gz5k = 2logixfg ) ( logout = 108249

  28. End

  29. Motivation

Recommend


More recommend