SlideShare a Scribd company logo
1 of 10
Lecture 15
B-Trees
Abirami Sivaprasad
Definition of a B-tree
• A B-tree of order m is an m-way tree (i.e., a tree where each
node may have up to m children) in which:
1. the number of keys in each non-leaf node is one less than the number
of its children and these keys partition the keys in the children in the
fashion of a search tree
2. all leaves are on the same level
3. all non-leaf nodes except the root have at least m / 2 children
4. the root is either a leaf node, or it has from two to m children
5. a leaf node contains no more than m – 1 keys
• The number m should always be odd
An example B-Tree
51 6242
6 12
26
55 60 7064 9045
1 2 4 7 8 13 15 18 25
27 29 46 48 53
A B-tree of order 5
containing 26 items
Note that all the leaves are at the same level
• Suppose we start with an empty B-tree and keys arrive in the
following order:1 12 8 2 25 5 14 28 17 7 52 16 48 68
3 26 29 53 55 45
• We want to construct a B-tree of order 5
• The first four items go into the root:
• To put the fifth item in the root would violate condition 5
• Therefore, when 25 arrives, pick the middle key to make a
new root
Constructing a B-tree
1 2 8 12
Constructing a B-tree (contd.)
1 2
8
12 25
6, 14, 28 get added to the leaf nodes:
1 2
8
12 146 25 28
Constructing a B-tree (contd.)
Adding 17 to the right leaf node would over-fill it, so we take the
middle key, promote it (to the root) and split the leaf
8 17
12 14 25 281 2 6
7, 52, 16, 48 get added to the leaf nodes
8 17
12 14 25 281 2 6 16 48 527
Constructing a B-tree (contd.)
Adding 68 causes us to split the right most leaf, promoting 48 to the
root, and adding 3 causes us to split the left most leaf, promoting 3
to the root; 26, 29, 53, 55 then go into the leaves
3 8 17 48
52 53 55 6825 26 28 291 2 6 7 12 14 16
Adding 45 causes a split of 25 26 28 29
and promoting 28 to the root then causes the root to split
Constructing a B-tree (contd.)
17
3 8 28 48
1 2 6 7 12 14 16 52 53 55 6825 26 29 45
Inserting into a B-Tree
• Attempt to insert the new key into a leaf
• If this would result in that leaf becoming too big, split the leaf
into two, promoting the middle key to the leaf’s parent
• If this would result in the parent becoming too big, split the
parent into two, promoting the middle key
• This strategy might have to be repeated all the way to the top
• If necessary, the root is split in two and the middle key is
promoted to a new root, making the tree one level higher
Exercise in Inserting a B-Tree
Insert the following keys to a 5-way B-tree:
3, 7, 9, 23, 45, 1, 5, 14, 25, 24, 13, 11, 8, 19, 4, 31, 35, 56

More Related Content

What's hot

Knowing our number harsh prajapati
Knowing our number  harsh prajapatiKnowing our number  harsh prajapati
Knowing our number harsh prajapativivekprajapatiankur
 
Divisibility Rules
Divisibility RulesDivisibility Rules
Divisibility Rulesjulie0505
 
Divisibility rules
Divisibility rulesDivisibility rules
Divisibility rulesHeidi Sager
 
Grade VI Chap 2 Math Part 1 Theory | Introduction - Whole Numbers
Grade VI Chap 2 Math Part 1 Theory | Introduction - Whole NumbersGrade VI Chap 2 Math Part 1 Theory | Introduction - Whole Numbers
Grade VI Chap 2 Math Part 1 Theory | Introduction - Whole Numbersaisha kanwal
 
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers Swapnil Deopurkar
 
Divisibility rules
Divisibility rulesDivisibility rules
Divisibility ruleswhernanm
 
Mathematics (Class VI) Day 1 chapter 1 Know our numbers
Mathematics (Class VI) Day 1 chapter 1   Know our numbersMathematics (Class VI) Day 1 chapter 1   Know our numbers
Mathematics (Class VI) Day 1 chapter 1 Know our numbersJasleen Samra
 
Divisability Rulesppt
Divisability RulespptDivisability Rulesppt
Divisability RulespptDonna Furrey
 
Divisibility rules 2 to 12
Divisibility rules 2 to 12Divisibility rules 2 to 12
Divisibility rules 2 to 12jennytuazon01630
 
Playing with numbers
Playing with numbersPlaying with numbers
Playing with numbersArnav Jain
 
Divisability rules
Divisability rulesDivisability rules
Divisability rulesNikki Sasser
 
MEAN MODE MEDIAN AND RANGE
MEAN MODE MEDIAN AND RANGEMEAN MODE MEDIAN AND RANGE
MEAN MODE MEDIAN AND RANGERidaZaman1
 
Report in al1[1]
Report in al1[1]Report in al1[1]
Report in al1[1]dytpq13
 
Stem & leaf plots + histograms
Stem & leaf plots + histogramsStem & leaf plots + histograms
Stem & leaf plots + histogramsListeningDaisy
 
Mean, Median and Mode
Mean, Median and ModeMean, Median and Mode
Mean, Median and ModeKhaliRoberson
 
Divisibility Rules
Divisibility RulesDivisibility Rules
Divisibility Rulesmmeddin
 
Divisibility rules
Divisibility rulesDivisibility rules
Divisibility rulesnourhadla
 

What's hot (20)

Knowing our number harsh prajapati
Knowing our number  harsh prajapatiKnowing our number  harsh prajapati
Knowing our number harsh prajapati
 
Divisibility Rules
Divisibility RulesDivisibility Rules
Divisibility Rules
 
Divisibility rules
Divisibility rulesDivisibility rules
Divisibility rules
 
Grade VI Chap 2 Math Part 1 Theory | Introduction - Whole Numbers
Grade VI Chap 2 Math Part 1 Theory | Introduction - Whole NumbersGrade VI Chap 2 Math Part 1 Theory | Introduction - Whole Numbers
Grade VI Chap 2 Math Part 1 Theory | Introduction - Whole Numbers
 
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
 
Divisibility rules
Divisibility rulesDivisibility rules
Divisibility rules
 
Mathematics (Class VI) Day 1 chapter 1 Know our numbers
Mathematics (Class VI) Day 1 chapter 1   Know our numbersMathematics (Class VI) Day 1 chapter 1   Know our numbers
Mathematics (Class VI) Day 1 chapter 1 Know our numbers
 
Divisability Rulesppt
Divisability RulespptDivisability Rulesppt
Divisability Rulesppt
 
Whole numbers
Whole numbersWhole numbers
Whole numbers
 
Divisibility rules 2 to 12
Divisibility rules 2 to 12Divisibility rules 2 to 12
Divisibility rules 2 to 12
 
Playing with numbers
Playing with numbersPlaying with numbers
Playing with numbers
 
Divisability rules
Divisability rulesDivisability rules
Divisability rules
 
MEAN MODE MEDIAN AND RANGE
MEAN MODE MEDIAN AND RANGEMEAN MODE MEDIAN AND RANGE
MEAN MODE MEDIAN AND RANGE
 
Divisibility Rules
Divisibility RulesDivisibility Rules
Divisibility Rules
 
Report in al1[1]
Report in al1[1]Report in al1[1]
Report in al1[1]
 
Stem & leaf plots + histograms
Stem & leaf plots + histogramsStem & leaf plots + histograms
Stem & leaf plots + histograms
 
Divisibility
DivisibilityDivisibility
Divisibility
 
Mean, Median and Mode
Mean, Median and ModeMean, Median and Mode
Mean, Median and Mode
 
Divisibility Rules
Divisibility RulesDivisibility Rules
Divisibility Rules
 
Divisibility rules
Divisibility rulesDivisibility rules
Divisibility rules
 

Similar to Lecture 9 b tree (20)

B trees2
B trees2B trees2
B trees2
 
B trees
B treesB trees
B trees
 
B trees
B treesB trees
B trees
 
B Tree in Data Structure
B Tree in Data StructureB Tree in Data Structure
B Tree in Data Structure
 
16807097.ppt b tree are a good data structure
16807097.ppt b tree are a good data structure16807097.ppt b tree are a good data structure
16807097.ppt b tree are a good data structure
 
Btrees
BtreesBtrees
Btrees
 
BTrees-fall2010.ppt
BTrees-fall2010.pptBTrees-fall2010.ppt
BTrees-fall2010.ppt
 
trees
trees trees
trees
 
08 B Trees
08 B Trees08 B Trees
08 B Trees
 
Btree
BtreeBtree
Btree
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 
B tree-180214044656
B tree-180214044656B tree-180214044656
B tree-180214044656
 
B tree
B  treeB  tree
B tree
 
Multi way&btree
Multi way&btreeMulti way&btree
Multi way&btree
 
B trees
B treesB trees
B trees
 
Presentation on b trees [autosaved]
Presentation on b trees [autosaved]Presentation on b trees [autosaved]
Presentation on b trees [autosaved]
 
Btrees
BtreesBtrees
Btrees
 
B tree by-jash acharya
B tree by-jash acharyaB tree by-jash acharya
B tree by-jash acharya
 
4-b-tree.ppt
4-b-tree.ppt4-b-tree.ppt
4-b-tree.ppt
 
B trees
B treesB trees
B trees
 

More from Abirami A

Lecture 3 time complexity
Lecture 3 time complexityLecture 3 time complexity
Lecture 3 time complexityAbirami A
 
Lecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionLecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionAbirami A
 
Lecture 1 introduction
Lecture 1 introductionLecture 1 introduction
Lecture 1 introductionAbirami A
 
Lecture 14 splay tree
Lecture 14 splay treeLecture 14 splay tree
Lecture 14 splay treeAbirami A
 
Lecture 16 graphs traversal
Lecture 16 graphs traversalLecture 16 graphs traversal
Lecture 16 graphs traversalAbirami A
 
Lecture 16 graph introduction
Lecture 16 graph introductionLecture 16 graph introduction
Lecture 16 graph introductionAbirami A
 
Lecture 6 disjoint set
Lecture 6 disjoint setLecture 6 disjoint set
Lecture 6 disjoint setAbirami A
 
Lecture 8 tree traversal
Lecture 8 tree traversalLecture 8 tree traversal
Lecture 8 tree traversalAbirami A
 
Lecture 7 bst
Lecture 7 bstLecture 7 bst
Lecture 7 bstAbirami A
 
Lecture 6 tree traversal
Lecture 6 tree traversalLecture 6 tree traversal
Lecture 6 tree traversalAbirami A
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptxAbirami A
 
Lecture 1 sorting insertion & shell sort
Lecture 1 sorting insertion & shell sortLecture 1 sorting insertion & shell sort
Lecture 1 sorting insertion & shell sortAbirami A
 

More from Abirami A (12)

Lecture 3 time complexity
Lecture 3 time complexityLecture 3 time complexity
Lecture 3 time complexity
 
Lecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionLecture 2 Data Structure Introduction
Lecture 2 Data Structure Introduction
 
Lecture 1 introduction
Lecture 1 introductionLecture 1 introduction
Lecture 1 introduction
 
Lecture 14 splay tree
Lecture 14 splay treeLecture 14 splay tree
Lecture 14 splay tree
 
Lecture 16 graphs traversal
Lecture 16 graphs traversalLecture 16 graphs traversal
Lecture 16 graphs traversal
 
Lecture 16 graph introduction
Lecture 16 graph introductionLecture 16 graph introduction
Lecture 16 graph introduction
 
Lecture 6 disjoint set
Lecture 6 disjoint setLecture 6 disjoint set
Lecture 6 disjoint set
 
Lecture 8 tree traversal
Lecture 8 tree traversalLecture 8 tree traversal
Lecture 8 tree traversal
 
Lecture 7 bst
Lecture 7 bstLecture 7 bst
Lecture 7 bst
 
Lecture 6 tree traversal
Lecture 6 tree traversalLecture 6 tree traversal
Lecture 6 tree traversal
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
 
Lecture 1 sorting insertion & shell sort
Lecture 1 sorting insertion & shell sortLecture 1 sorting insertion & shell sort
Lecture 1 sorting insertion & shell sort
 

Recently uploaded

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 

Recently uploaded (20)

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 

Lecture 9 b tree

  • 2. Definition of a B-tree • A B-tree of order m is an m-way tree (i.e., a tree where each node may have up to m children) in which: 1. the number of keys in each non-leaf node is one less than the number of its children and these keys partition the keys in the children in the fashion of a search tree 2. all leaves are on the same level 3. all non-leaf nodes except the root have at least m / 2 children 4. the root is either a leaf node, or it has from two to m children 5. a leaf node contains no more than m – 1 keys • The number m should always be odd
  • 3. An example B-Tree 51 6242 6 12 26 55 60 7064 9045 1 2 4 7 8 13 15 18 25 27 29 46 48 53 A B-tree of order 5 containing 26 items Note that all the leaves are at the same level
  • 4. • Suppose we start with an empty B-tree and keys arrive in the following order:1 12 8 2 25 5 14 28 17 7 52 16 48 68 3 26 29 53 55 45 • We want to construct a B-tree of order 5 • The first four items go into the root: • To put the fifth item in the root would violate condition 5 • Therefore, when 25 arrives, pick the middle key to make a new root Constructing a B-tree 1 2 8 12
  • 5. Constructing a B-tree (contd.) 1 2 8 12 25 6, 14, 28 get added to the leaf nodes: 1 2 8 12 146 25 28
  • 6. Constructing a B-tree (contd.) Adding 17 to the right leaf node would over-fill it, so we take the middle key, promote it (to the root) and split the leaf 8 17 12 14 25 281 2 6 7, 52, 16, 48 get added to the leaf nodes 8 17 12 14 25 281 2 6 16 48 527
  • 7. Constructing a B-tree (contd.) Adding 68 causes us to split the right most leaf, promoting 48 to the root, and adding 3 causes us to split the left most leaf, promoting 3 to the root; 26, 29, 53, 55 then go into the leaves 3 8 17 48 52 53 55 6825 26 28 291 2 6 7 12 14 16 Adding 45 causes a split of 25 26 28 29 and promoting 28 to the root then causes the root to split
  • 8. Constructing a B-tree (contd.) 17 3 8 28 48 1 2 6 7 12 14 16 52 53 55 6825 26 29 45
  • 9. Inserting into a B-Tree • Attempt to insert the new key into a leaf • If this would result in that leaf becoming too big, split the leaf into two, promoting the middle key to the leaf’s parent • If this would result in the parent becoming too big, split the parent into two, promoting the middle key • This strategy might have to be repeated all the way to the top • If necessary, the root is split in two and the middle key is promoted to a new root, making the tree one level higher
  • 10. Exercise in Inserting a B-Tree Insert the following keys to a 5-way B-tree: 3, 7, 9, 23, 45, 1, 5, 14, 25, 24, 13, 11, 8, 19, 4, 31, 35, 56