Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science Department

Similar presentations


Presentation on theme: "Computer Science Department"— Presentation transcript:

1 Computer Science Department
B/B+ Trees Dr. Tom Hicks Computer Science Department Trinity University

2 4 General Requirements For
BTrees & B+Trees

3 4 B/B+ Tree Requirements
Nodes Contain M - 1 Records Nodes Contain M Pointers To Other B Tree Nodes Nodes Contain NoRecords Counter Every Node, Except The Root, Shall Always Be At Least Half Full

4 Also Called “M-Way Trees”
About BTrees Also Called “M-Way Trees”

5 About B Trees & B+ Trees The Rotations  ASSOCIATED WITH INSERTIONS & DELETIONS  Are The Same For B Trees & B+ Trees There Are a Number of Ways to Implement B+ Trees Some Approaches Store All Key Sets In The Leaves Some Approaches Store Key Sets In The Nodes I am going to Describe/Demo the Techniques I feel are the Easiest To Code.

6 Original B Tree Paper Original B+ Tree Paper
The B Tree Was First Described In The Paper: Organization and Maintenance of Large Ordered Indices. Acta Informatica 1: 173–189 (1972) by Rudolf Bayer & Edward M. McCreight. Original B+ Tree Paper NONE  There Is No Single Paper Introducing The B+ Tree Concept. The B+ Tree Is Often Considered a Variant Of The B Tree

7 B+ Trees  Database Systems
The B+ Trees Form The Foundation For Most Of Today’s Major Relational Databases.

8 BTrees Were First  Almost Never Used
The BTree Node M-Way Tree BTrees Were First  Almost Never Used

9 B Tree Node Structure - 1 M - 1 Data Records  Of InfoType
Suppose We  # define M 5 [Will Branch Off 5 Ways] Each Node Will Contain: M - 1 Data Records  Of InfoType 1 2 3 Some Implementations Store All Of The Data In The Leaf Nodes - I Find This More Difficult To Code; This Requires 2 Different Types Of Nodes. I Choose To Use One Type Of Node; Each Node Will Include M-1 InfoType Records.

10 B Tree Node Structure - 2 M - 1 Data Records Of InfoType
Suppose We  # define M 5 Each Node Will Contain: M - 1 Data Records Of InfoType Contain M Pointers To Other B Tree Nodes 1 2 3

11 B Tree Node Structure - 3 M - 1 Data Records Of InfoType
Suppose We  # define M 5 Each Node Will Contain: M - 1 Data Records Of InfoType M Pointers To Other B Tree Nodes NoRecords Counter 1 2 3 NoRecords

12 BTree Node Structure In Internal Memory

13 C++ Implementation Of B Tree Node
# define M 5 template <class InfoType> class BTreeNode { public: private: InfoType Info[M-1]; NodePtr Ptrs[M]; long int NoRecords; }; 1 2 3 / BTreeNode(void); 40,008 Assume that sizeof(InfoType) = 9, sizeof(BTreeNode) = __________

14 Calculating The Size Of A
BTree Node

15 C++ Implementation Might BeB Tree Node
Size Of A Of B Tree Node M = 5  sizeof(InfoType) = 9,996 C++ Implementation Might BeB Tree Node = (M-1) x 9996 = 4 x 9996 = 39,984 1 2 3 + 1 2 3 = (M) x 4 = 5 x 4 = 20 + 1 2 3 = 4 40,008 sizeof(BTreeNode) = __________

16 As M Increases, This Node Is Going To Get Really Big Really Fast!
C++ Implementation Of B Tree Node 1 2 3 4 5 6 7 8 9 / # define M 11 template <class InfoType> class BTreeNode { public: private: InfoType Info[M-1]; NodePtr Ptrs[M]; long int NoRecords; }; BTreeNode(void); As M Increases, This Node Is Going To Get Really Big Really Fast! 100,008 Assume that sizeof(InfoType) = 9, sizeof(BTreeNode) = __________

17 Adding The First Couple Records To A
BTree Node

18 B Tree Node - Adding Data -1
Data Record 1: Part Object - Primary Key = Part Name  Name = Football, ID = 101, etc. 1 2 3 FB ……………… / / / / / 1 Data in each node will be maintained in sorted order  by Key

19 B Tree Node - Adding Data -2
Data Record 2: Part Object - Primary Key = Part Name  Name = Basketball, ID = 142, etc. 1 2 3 FB ……………… BB ……………… / / / / / 2 Data in each node will be maintained in sorted order  by Key

20 B+ Trees Use The Same Key Sets Introduced In CSCI 2320
Key Sets Are Used In Key Tables & B+ Tree Nodes

21 B+ Tree Nodes Key Set This KeySet <KeyType> Class is used for:
Ptr This KeySet <KeyType> Class is used for: Internal Memory Key Tables For Linked Lists, Binary Trees, AVL Trees, etc. Direct Access File Key Tables For Linked Lists, Binary Trees, AVL Trees, etc. B+ Tree Nodes

22 BTrees Were First  Almost Never Used
The B+ Tree Node M-Way Tree BTrees Were First  Almost Never Used

23 B+ Tree Node Structure - 1
Suppose We  # define M 5 [Will Branch Off 5 Ways] Each Node Will Contain: M - 1 Key Sets  (Each With A Key & A PTR) Key PTR 1 2 3

24 B+ Tree Node Structure - 2
Suppose We  # define M 5 Each Node Will Contain: M - 1 Key Sets M Pointers To Other B+ Tree Nodes Key PTR 1 2 3

25 B+ Tree Node Structure - 3
Suppose We  # define M 5  Suppose The Key is 4 Bytes Each Node Will Contain: M - 1 Key Sets M Pointers To Other B+ Tree Nodes NoRecords Counter Key (4) PTR(4) NoRecords 1 2 3 Direct Access File 1 2 3 InfoType Data Records Will Be Stored In Direct Access Data File

26 Calculating The Size Of A
B+Tree Node

27 M = 5  sizeof(InfoType) = 9,996 sizeof Key = 4
Size Of A Of B Tree Node M = 5  sizeof(InfoType) = 9, sizeof Key = 4 = (M-1) x 4 = 4 x 4 = 16 1 2 3 + 1 2 3 = (M) x 4 = 5 x 4 = 20 + 1 2 3 = 4 40 sizeof(B+TreeNode) = __________

28 BTree Node Structure C++

29 C++ Implementation Of B Tree Node
# define M  KeyType = 4 Bytes InfoType = Bytes template <class InfoType, class KeyType> class B+TreeNode { public: private: KeySet <KeyType> Keys[M-1]; NodePtr Ptrs[M]; long int NoRecords; }; 1 2 3 4 5 6 7 8 9 / B+TreeNode(void); 128 Assume that sizeof(InfoType) = 9, sizeof(B+TreeNode) = __________ Assume that sizeof(KeyType) = 4

30 Adding The First Couple Records To A
B+ Tree Node Requires An Extra File

31 B Tree Node - Adding Data -1
Data Record 1: Part Object - Primary Key = Part Name  Name = Football, ID = 101, etc.  Extra File Needed! Key PTR 1 2 3 1 2 3 4 5 6 7 FB / / / / / 1 Football ……………… Data in each node will be maintained in sorted order  by Key

32 B Tree Node - Adding Data -2
Data Record 2: Part Object - Primary Key = Part Name  Name = Basketball, ID = 142, etc. Key PTR 1 2 3 1 2 3 4 5 6 7 BB FB FB FB / / / / / 2 Basketball ……………… Football ……………… Data in each node will be maintained in sorted order  by Key

33 B Tree Rotations The Keys Will Often Contain Duplicates, But I Am Going To Avoid Them For The Moment!

34 [0] Node File Record 1 BTree <InfoType> Tree1(5); 1 2 3 / 1 2 3 [0] Node File Record 1 / 200 Tree1.Inplace(1,200); Tree1.Inplace(1,100); 1 2 3 [0] Node File Record 1 / 100 200 Records Are Sorted In Ascending Order By Key Within Each Node==========> Tree1.Inplace(1,400);

35 B Tree Split! BTree <InfoType> Tree1(5); 1 2 3
1 2 3 [0] Node File Record 1 / 100 200 400 Tree1.Inplace(1,400); Tree1.Inplace(1,500); 1 2 3 [0] Node File Record 1 / 4 100 200 400 500 Tree1.Inplace(1,300); B Tree Split!

36 Middle Record Goes Up One Level - Create Node If Need!
500 0verflow Container 3 400 Tree1.Inplace(1,300); 2 300 [1] 1 200 100 / / / / / 4 1 2 3 / 300 [2] Middle Record Goes Up One Level - Create Node If Need! 300 Tree1.Inplace(1,300) - done 1 2 3 / 100 200 [1] 1 2 3 / 400 500 [3]

37 Tree1.Inplace(1,600); 1 2 3 / 300 [2] 1 2 3 / 100 200 [1] 1 2 3 / 400 500 [3]

38 Tree1.Inplace(1,600) - done Tree1.Inplace(1,700); 1 2 3 / 300 [2] 1 2 3 / 100 200 [1] 1 2 3 / 400 500 [3] 600

39 Tree1.Inplace(1,700) - done Tree1.Inplace(1,50); 1 2 3 / 300 [2] 1 2 3 / 100 200 [1] 1 2 3 / 4 400 500 [3] 700 600

40 Tree1.Inplace(1,50) - done Tree1.Inplace(1,250); 1 2 3 / 300 [2] 1 2 3 / 50 100 [1] 1 2 3 / 4 400 500 [3] 700 200 600

41 Tree1.Inplace(1,250) - done Tree1.Inplace(1,800); 1 2 3 / 300 [2] 1 2 3 / 4 50 100 [1] 250 1 2 3 / 4 400 500 [3] 700 200 600

42 Middle Record Goes Up One Level - Create Node If Need!
Tree1.Inplace(1,800); Middle Record Goes Up One Level - Create Node If Need! 600 Split 1/3 1 2 3 / 300 [2] 0verflow Container 800 1 2 3 / 4 50 100 [1] 250 1 2 3 / 4 400 500 [3] 700 200 600

43 Tree1.Inplace(1,800) - cont Split 2/3 1 2 3 / 300 [2] 600 0verflow Container 800 1 2 3 / 4 50 100 [1] 250 1 2 3 / 4 400 500 [3] 700 200

44 Tree1.Inplace(1,800) - done Split 3/3 1 2 3 4 / 300 [2] 600 1 2 3 / 4 50 100 [1] 200 250 1 2 3 / 400 500 [3] 1 2 3 / 700 800 [4]

45 1 2 3 4 / 300 [2] Tree1.Inplace(1,150); 600 1 2 3 / 4 50 100 [1] 200 250 1 2 3 / 400 500 [3] 1 2 3 / 700 800 [4]

46 Middle Record Goes Up One Level - Create Node If Need!
Tree1.Inplace(1,150) Middle Record Goes Up One Level - Create Node If Need! 150 Split 1/3 1 2 3 4 / 300 [2] 600 0verflow Container 250 1 2 3 / 4 50 100 [1] 150 200 1 2 3 / 400 500 [3] 1 2 3 / 700 800 [4]

47 1 2 3 ? 4 / 150 [2] Tree1.Inplace(1,150) - cont 600 300 Split 2/3 250 1 2 3 / 4 50 100 [1] 200 1 2 3 / 400 500 [3] 1 2 3 / 700 800 [4]

48 1 2 3 5 4 / 150 [2] 600 Tree1.Inplace(1,150) - done 300 Split 3/3 1 2 3 / 50 100 [1] 1 2 3 / 200 250 [5] 1 2 3 / 400 500 [3] 1 2 3 / 700 800 [4]

49 1 2 3 5 4 / 150 [2] 600 300 Tree1.Inplace(1,550); 1 2 3 / 50 100 [1] 1 2 3 / 200 250 [5] 1 2 3 / 400 500 [3] 1 2 3 / 700 800 [4]

50 1 2 3 5 4 / 150 [2] 600 Tree1.Inplace(1,550) - done 300 Tree1.Inplace(1,450); 1 2 3 / 50 100 [1] 1 2 3 / 200 250 [5] 1 2 3 / 400 500 [3] 1 2 3 / 700 800 [4] 550

51 1 2 3 5 4 / 150 [2] 600 Tree1.Inplace(1,450) - done 300 Tree1.Inplace(1,350); 1 2 3 / 50 100 [1] 1 2 3 / 200 250 [5] 1 2 3 / 4 400 450 [3] 1 2 3 / 700 800 [4] 550 500

52 Middle Record Goes Up One Level - Create Node If Need!
1 2 3 5 4 / 150 [2] 600 Tree1.Inplace(1,350) 300 Middle Record Goes Up One Level - Create Node If Need! 450 Split 1/3 1 2 3 / 50 100 [1] 550 1 2 3 / 200 250 [5] 1 2 3 / 4 350 400 [3] 1 2 3 / 700 800 [4] 500 450

53 1 2 3 5 ? 4 150 [2] 600 450 Tree1.Inplace(1,350) - cont 300 Split 2/3 1 2 3 / 700 800 [4] 1 2 3 / 50 100 [1] 550 1 2 3 / 200 250 [5] 1 2 3 / 4 350 400 [3] 500

54 1 2 3 5 6 4 150 [2] 600 450 Tree1.Inplace(1,350) - done 300 Split 3/3 1 2 3 / 700 800 [4] 1 2 3 / 50 100 [1] 1 2 3 / 200 250 [5] 1 2 3 / 350 400 [3] 1 2 3 / 500 550 [6]

55 1 2 3 5 6 4 150 [2] 600 450 Tree1.Inplace(1,750) 300 1 2 3 / 700 800 [4] 1 2 3 / 50 100 [1] 1 2 3 / 200 250 [5] 1 2 3 / 350 400 [3] 1 2 3 / 500 550 [6]

56 1 2 3 5 6 4 150 [2] 600 450 Tree1.Inplace(1,750) - done 300 Tree1.Inplace(1,850); 1 2 3 / 700 750 [4] 1 2 3 / 50 100 [1] 800 1 2 3 / 200 250 [5] 1 2 3 / 350 400 [3] 1 2 3 / 500 550 [6]

57 1 2 3 5 6 4 150 [2] 600 450 Tree1.Inplace(1,850) - done 300 Tree1.Inplace(1,900); 1 2 3 / 4 700 750 [4] 1 2 3 / 50 100 [1] 850 800 1 2 3 / 200 250 [5] 1 2 3 / 350 400 [3] 1 2 3 / 500 550 [6]

58 1 2 3 5 6 4 150 [2] 600 800 450 Tree1.Inplace(1,900) 300 Split 1/8 900 1 2 3 / 4 700 750 [4] 1 2 3 / 50 100 [1] 850 800 1 2 3 / 200 250 [5] 1 2 3 / 350 400 [3] 1 2 3 / 500 550 [6]

59 800 450 1 2 3 5 6 4 150 [2] 600 Tree1.Inplace(1,900) 450 300 Split 2/8 900 1 2 3 / 4 700 750 [4] 1 2 3 / 50 100 [1] 850 1 2 3 / 200 250 [5] 1 2 3 / 350 400 [3] 1 2 3 / 500 550 [6]

60 Ignore This Portion For The Moment
800 450 1 2 3 5 6 4 150 [2] 600 Tree1.Inplace(1,900) 450 300 Split 3/8 Ignore This Portion For The Moment

61 Ignore This Portion For The Moment
1 2 3 / 450 [7] Tree1.Inplace(1,900) Split 4/8 800 1 2 3 5 6 4 150 300 [2] 600 Ignore This Portion For The Moment

62 Back To The Portion We Ignored!
1 2 3 8 / 450 [7] Tree1.Inplace(1,900) Split 5/8 1 2 3 5 6 4 150 300 [2] 1 2 3 / 600 800 [8] Back To The Portion We Ignored!

63 ?? 1 2 3 / 450 [7] Tree1.Inplace(1,900) Split 6/8 1 2 3 5 / 150 300
1 2 3 / 450 [7] Tree1.Inplace(1,900) Split 6/8 1 2 3 5 / 150 300 [2] 1 2 3 / 600 800 [8] ?? 1 2 3 / 50 100 [1] 200 250 [5] 350 400 [3]

64 ?? 1 2 3 / 450 [7] Tree1.Inplace(1,900) Split 7/8 1 2 3 5 / 150 300
1 2 3 / 450 [7] Tree1.Inplace(1,900) Split 7/8 1 2 3 5 / 150 300 [2] 1 2 3 / 600 800 [8] ?? 1 2 3 / 4 700 750 [4] 850 900 1 2 3 / 50 100 [1] 200 250 [5] 350 400 [3] 1 2 3 / 500 550 [6]

65 1 2 3 / 450 [7] Tree1.Inplace(1,900) Split 8/8 1 2 3 5 / 150 300 [2] 1 2 3 6 4 9 / 600 800 [8] 1 2 3 / 50 100 [1] 200 250 [5] 350 400 [3] 1 2 3 / 500 550 [6] / 2 700 750 [4] / 2 850 900 [9] 3 2 1

66 B+ Tree / B Tree Root Node

67 About B Trees & B+ Trees The Root Node Is Kept In Memory
On A Blade Server, All B/B+ Tree Nodes May Be Kept In Memory.

68 Read-Write Buffers

69 Tracks, Sectors, Blocks, Clusters
Your operating system defines a buffer size; it can be changed by code and utility programs (such as the one produced by AnalogX). Read/Write Buffers will vary and can be changed.

70 Buffers Can Be Configured - 1
Run A Command Window In Administrative Mode

71 Buffers Can Be Configured - 2
Run The DISKPART Utility

72 Buffers Can Be Configured - 3
List The Volumes On Your Computer

73 Buffers Can Be Configured - 4
Select One Of Your Volumes To Be The Default Volume 2 is an 8 TB Drive

74 Buffers Can Be Configured - 5
Look At The File System On The Default Volume

75 Buffers Can Be Configured - 6
The Smallest Unit (4096) is the Block Size The Ideal Buffer Sizes Are 4K, 8K, 16K, 32K, 64K, 128K, 256K, 512K, 1024K, & 2048K The Ideal Buffer Sizes Are 1 Block, 2 Blocks, 4 Blocks, 8 Blocks, 16 Blocks, 32 Blocks, 32 Blocks, 64 Blocks, 128 Blocks, 256 Blocks, Blocks, & 2048 Blocks Microsoft Tells Me You Can Set The Buffers To Values In-Between.

76 Buffers Can Be Configured - 7
I am Going To Select Volume 3 Volume 3 Is The Small Boot Partition MB Filesystem  Part Of It Is FAT32 Many Of The Older Drives Have A 512 Byte NTFS Partition!

77 That Was A Bunch Of Hardware "Stuff"
Why Do We Care? What Does This Have To Do With Database Design?

78 We May Write Our Applications With A Database
We Have To Understand The Logic To Include Timing In Our Requirements In Specifications

79 Databases Often Calculate The Optimal M
Suppose We Considered Doing So For A B Tree

80 Database – Optimize Buffer Usage – B Tree
Suppose Our Buffer Size = 30 Blocks (4096 Bytes Each) InfoType = 9,996 Bytes  Key = 4 Bytes Implementation: B Tree Buffer Size = 4096 x 30 = 122,880 Calculate M? (M – 1) x 9,996 1 2 3 + M x 4 + 4 <= 122,880 9,996 M + 4 M – 9, <= 122,880 10,000 M <= 122, ,992 10,000 M <= 132,872 M = 13

81 B Tree  M = 13 #1 Assume Each Level Fully Populated  Suppose We Had 1,000,000 Records
Max Records In First Level = _________ 12 Max Records In Second Level = __________________ 156 13 x 12 = 156 Min Records In Second Level = ___________________ 78 13 x 6 = 78 Avr Records In Second Level = ___________________ 117 13 x 9 = 117 Max Records In Third Level = _____________________ 2,028 13 x 13 x 12 = 2,028 Min Records In Third Level = _____________________ 1,014 13 x 13 x 6 = 1,014

82 B Tree  M = 13 #2 Assume Each Level Fully Populated  Suppose We Had 1,000,000 Records
Max Records In Third Level = _____________________ 26,364 13 x 13 x 13 x 12 = 26,364 Min Records In Third Level = _____________________ 13,182 13 x 13 x 13 x 6 = 13,182 Max Records In Fourth Level = ____________________ 342,732 13 x 13 x 13 x 13 x 12 = 342,732 Min Records In Fourth Level = ____________________ 171,366 13 x 13 x 13 x 13 x 6 = 171,366 Max Records In Fifth Level = ______________________ 4,455,516 13 x 13 x 13 x 13 x 13 x 12 = 4,455,516 Min Records In Fifth Level = ______________________ 2,227,758 13 x 13 x 13 x 13 x 13 x 12 = 2,227,758

83 B Tree  M = 13 #3 Assume Each Level Fully Populated  Suppose We Had 1,000,000 Records
Min Records In Fifth Level = ______________________ 2,227,758 13 x 13 x 13 x 13 x 13 x 12 = 2,227,758 SEARCH  Root In Memory  Read Down 4 Levels ADD  Root In Memory  Read Down 4 Levels Update Leaf Node  Write Direct Access Record DELETE  Root In Memory  Read Down 4 Levels Update Leaf Node  Delete Direct Access Record If We Knew The Time Required To Read/Write Nodes & Records, We Could Determine If We Could Meet Our Specifications.

84 B Tree  M = 13 #4 Assume Each Level Fully Populated  Suppose We Had 1,000,000 Records
Min Records In Fifth Level = ______________________ 2,227,758 13 x 13 x 13 x 13 x 13 x 12 = 2,227,758 Better Than An AVL Tree? YES - Evenly If Perfectly Balanced  20 Levels But Don't Get Too Satisfied Yet  There Are Reasons That We Seldom, If Ever, Use B Trees.

85 B+ Tree - The Keys Are Not Always 4 Bytes
InfoType = 9,996 Bytes  Key = 16 Byte Part Name Implementation: B Tree Buffer Size = 4096 x 30 = 122,880 Calculate M? (M – 1) x 20 1 2 3 + M x 4 + 4 <= 122,880 20 M – M + 4 <= 122,880 24 M <= 122, 24 M <= 122,896 M = 5,120

86 Databases Often Calculate The Optimal M
Suppose We Considered Doing So For A B+ Tree

87 Database – Optimize Buffer Usage B+ Tree
InfoType = 9,996 Bytes  Key = 4 Byte Bar Code Implementation: B Tree Buffer Size = 4096 x 30 = 122,880 Calculate M? (M – 1) x 8 1 2 3 + M x 4 + 4 <= 122,880 8 M – M + 4 <= 122,880 12 M <= 122, 12 M <= 122,884 M = 10,240

88 B+ Tree  M = 10,240 #1 Assume Each Level Fully Populated  Suppose We Had 1,000,000 Records
Max Records In First Level = __________________________ 10,239 Min Records In First Level = __________________________ 5,120 Max Records In Second Level = _______________________ 104,847,360 10,240 x 10,239 = 104,847,360 Min Records In Second Level = _______________________ 52,428,800 10,240 x 5,120 = 52,428,800 DONE! Max Records In Third Level = _______________________ 1,073,363,966,400 10,240 x 10,240 x 10,239 = 1,073,363,966,400

89 B+ Tree  M = 10,240 #2 Assume Each Level Fully Populated  Suppose We Had 1,000,000 Records
Min Records In Second Level = _______________________ 52,428,800 10,240 x 5,120 = 52,428,800 SEARCH  Root In Memory  Read Down 1 Level - Read DA ADD  Root In Memory  Read Down 1 Level Update Leaf Node  Write Direct Access Record DELETE  Root In Memory  Read Down 1 Level Update Leaf Node  Delete Direct Access Record If We Knew The Time Required To Read/Write Nodes & Records, We Could Determine If We Could Meet Our Specifications.

90 Why B+ Trees

91 Advantages Of B+ Trees (IMPORTANT) - 1
1 - Searching Is Faster  Fewer Levels Required 2 - Adding New Records Is Faster  Fewer Levels Required 3 - Deleting Old Records Is Faster  Fewer Levels Required 4 - Less Waste  Would You Rather Waste 25 % Of Records With 8 Byte Key Sets or 9,996 Byte Records?

92 B Trees  Two Keys - What If More?
Suppose We Wanted To Be Able To Search By Part Name & Part No?  Name = Football, ID = 101, etc.  Name = Basketball, ID = 142, etc. 1 2 3 / BB ……………… FB ……………… Part Name 1 2 3 / 101 FB ……………… 142 BB ……………… Part No 9,996 Bytes Can You Imagine The Wasted Space & The Difficulties Associated With Keeping The Records In Synch?

93 B+ Trees  Two Keys - What If More?
Suppose We Wanted To Be Able To Search By Part Name & Part No?  Name = Football, ID = 101, etc.  Name = Basketball, ID = 142, etc. 1 2 3 / Key PTR 8 Bytes 1 2 3 / BB Key PTR 24 Bytes FB 1 2 3 4 5 6 Football 101 ……… 9,996 Bytes Basketball 142 …… v

94 Is It Any Wonder That No One Uses B Trees?
Advantages Of B+ Trees (IMPORTANT) - 5 5 - B+ Trees Manage Multiple Keys Much More Efficiently B+ Trees  Multiple Keys Can Be Created To Point to One Common Record Set Is It Any Wonder That No One Uses B Trees?

95 Searching Algorithm Is Pretty Easy!
This Example Uses Internal Memory Solution - Not Files

96 Internal Memory B-Tree
B-Tree-Search(x, k) i <- 1 while i <= n[x] and k > keyi[x] do i <- i + 1 if i <= n[x] and k = keyi[x] then return (x, i) if leaf[x] then return NIL else Disk-Read(ci[x]) return B-Tree-Search(ci[x], k)


Download ppt "Computer Science Department"

Similar presentations


Ads by Google