SlideShare a Scribd company logo
Chapter 15 B
External Methods –
B-Trees
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-2
B-Trees
• To organize the index file as an external search tree
– Use block numbers for child pointers
• A child pointer value of –1 is used as the null pointer
Figure 15.10a –Figure 15.10a – Blocks organized into a 2-3 tree
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-3
B-Trees
• If the index file is organized into a 2-3 tree
– Each node would contain
• Either one or two index records, each of the form
<key, pointer>
• Three child pointers
Figure 15.10b –Figure 15.10b – A single node of the 2-3 tree
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-4
B-Trees
• An external 2-3 tree is adequate, but an
improvement is possible
• To improve efficiency
– Allow each node to have as many children as possible
• In an external environment, the advantage of keeping a search
tree short far outweighs the disadvantage of performing extra
work at each node
• Block size should be the only limiting factor for the number of
children
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-5
B-Trees
• Binary search tree
– If a node N has two children, it must contain one key
value
• 2-3 tree
– If a node N has three children, it must contain two key
values
• General search tree
– If a node N has m children, it must contain m – 1 key
values
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-6
B-Trees
Figure 15.11Figure 15.11
a) A node with two children; b) a node with three children; c) a node with m children
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-7
B-Trees
• B-tree of degree m
– All leaves are at the same level
– Nodes
• Each node contains between m – 1 and m/2 records
• Each internal node has one more child than it has records
• Exception: The root can contain as few as one record and can
have as few as two children
– Example
• A 2-3 tree is a B-tree of degree 3
– Each node contains between (3-1) = 2 and 3/2 = 1 records.
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-8
B-Trees
Figure 15.13Figure 15.13
A B-tree of degree 5
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-9
B-Trees
• Retrieval
– Generalized search tree retrieval
• Insertion into a B-tree
– Step 1: Insert the data record into the data file
– Step 2: Insert a corresponding index record into
the index file
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-10
B-Trees
Figure 15.14a and bFigure 15.14a and b
The steps for inserting 55
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-11
B-Trees
Figure 15.14c-eFigure 15.14c-e
The steps for inserting 55
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-12
B-Trees
• Deletion from a B-tree
– Step 1: Locate the index record in the index file
and delete it from the index file
– Step 2: Delete the data record from the data file
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-13
B-Trees
Figure 15.15a and bFigure 15.15a and b
The steps for deleting 73
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-14
B-Trees
Figure 15.15cFigure 15.15c
The steps for deleting 73
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-15
B-Trees
Figure 15.15dFigure 15.15d
The steps for deleting 73
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-16
B-Trees
Figure 14.15e and fFigure 14.15e and f
The steps for deleting 73
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-17
Traversals
• Accessing only the search key of each record, not
the data file
– Not efficiently supported by the hashing
implementation
– Efficiently supported by the B-tree implementation
• The search keys can be visited in sorted order by using an
inorder traversal of the B-tree
• Accessing the entire data record
– Not efficiently supported by the B-tree implementation
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-18
Multiple Indexing
• Advantage
– Allows multiple data organizations
• Disadvantage
– More storage space
– Additional overhead for updating each index
whenever the data file is modified
© 2004 Pearson Addison-Wesley. All rights reserved 15 B-19
Multiple Indexing
Figure 15.16Figure 15.16
Multiple index files
Chi-Cheng Lin, Winona State University 20
Variations of B-Trees
• The fewer nodes are in a B-tree, the better.
(Why?)
• Problems of B-tree:
– It could be only half full
• More nodes required
• Space wasted
– Inorder traversal “jumps” around nodes
• B*
-Trees: introduced by Donald Knuth
• B+
-Trees: introduced by H. Wedekind
Chi-Cheng Lin, Winona State University 21
B*
-Trees
• B*
-tree of degree m
– All leaves are at the same level
– Nodes
• Each node contains between m – 1 and (2m – 1)/3 records
• Each internal node has one more child than it has records
• Exception: The root can contain as few as one record and as
many as (2m-2) children
– Example
• B*
-tree of degree 9
– Each node contains between (9 – 1) = 8 and (2×9 – 1)/3 = 5
records.
Chi-Cheng Lin, Winona State University 22
B*
-Trees
• Splitting nodes
– When a node overflows, it is not split right away
– A split is delayed by redistributing the keys between a
node and its sibling
– When both a node and its sibling are full, an insertion
to the node will split the two nodes into three nodes
• A B*-Tree is always two-third full instead of half
full  number of nodes in the tree is reduced
Chi-Cheng Lin, Winona State University 23
B*
-Trees
Chi-Cheng Lin, Winona State University 24
B+
-Trees
• References to data are only made from the
leaves
– All index records can be found from the leaves
• Two sets of nodes
– Index set
• Internal nodes
• Provides fast access of data
– Sequence set
• Leaves, linked sequentially
• Provides efficient inorder traversal
Chi-Cheng Lin, Winona State University 25
B+
-Trees
Ad

More Related Content

Viewers also liked (9)

B trees
B treesB trees
B trees
PRAKASH RANJAN SINGH
 
Algorithm Introduction #18 B-Tree
Algorithm Introduction #18 B-TreeAlgorithm Introduction #18 B-Tree
Algorithm Introduction #18 B-Tree
Satoshi Asano
 
Лекция 5: B-деревья (B-trees, k-way merge sort)
Лекция 5: B-деревья (B-trees, k-way merge sort)Лекция 5: B-деревья (B-trees, k-way merge sort)
Лекция 5: B-деревья (B-trees, k-way merge sort)
Mikhail Kurnosov
 
B trees and_b__trees
B trees and_b__treesB trees and_b__trees
B trees and_b__trees
meghu123
 
CAD: introduction to floorplanning
CAD:  introduction to floorplanningCAD:  introduction to floorplanning
CAD: introduction to floorplanning
Team-VLSI-ITMU
 
floor planning
floor planningfloor planning
floor planning
Team-VLSI-ITMU
 
Best for b trees
Best for b treesBest for b trees
Best for b trees
DineshRaaja
 
Examining Mac File Structures
Examining Mac File StructuresExamining Mac File Structures
Examining Mac File Structures
primeteacher32
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
Intro C# Book
 
Algorithm Introduction #18 B-Tree
Algorithm Introduction #18 B-TreeAlgorithm Introduction #18 B-Tree
Algorithm Introduction #18 B-Tree
Satoshi Asano
 
Лекция 5: B-деревья (B-trees, k-way merge sort)
Лекция 5: B-деревья (B-trees, k-way merge sort)Лекция 5: B-деревья (B-trees, k-way merge sort)
Лекция 5: B-деревья (B-trees, k-way merge sort)
Mikhail Kurnosov
 
B trees and_b__trees
B trees and_b__treesB trees and_b__trees
B trees and_b__trees
meghu123
 
CAD: introduction to floorplanning
CAD:  introduction to floorplanningCAD:  introduction to floorplanning
CAD: introduction to floorplanning
Team-VLSI-ITMU
 
Best for b trees
Best for b treesBest for b trees
Best for b trees
DineshRaaja
 
Examining Mac File Structures
Examining Mac File StructuresExamining Mac File Structures
Examining Mac File Structures
primeteacher32
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
Intro C# Book
 

Similar to 1.9 b tree (7)

Data structures trees - B Tree & B+Tree.pptx
Data structures trees - B Tree & B+Tree.pptxData structures trees - B Tree & B+Tree.pptx
Data structures trees - B Tree & B+Tree.pptx
MalligaarjunanN
 
B+ tree.pptx
B+ tree.pptxB+ tree.pptx
B+ tree.pptx
Maitri Shah
 
Adbms 22 dynamic multi level index using b and b+ tree
Adbms 22 dynamic multi level index using b  and b+ treeAdbms 22 dynamic multi level index using b  and b+ tree
Adbms 22 dynamic multi level index using b and b+ tree
Vaibhav Khanna
 
btrees.ppt ttttttttttttttttttttttttttttt
btrees.ppt  tttttttttttttttttttttttttttttbtrees.ppt  ttttttttttttttttttttttttttttt
btrees.ppt ttttttttttttttttttttttttttttt
RAtna29
 
M.E - Computer Science and Engineering-Data structure B tree
M.E - Computer Science and Engineering-Data structure B treeM.E - Computer Science and Engineering-Data structure B tree
M.E - Computer Science and Engineering-Data structure B tree
poonkodiraja2806
 
4-b-tree.ppt
4-b-tree.ppt4-b-tree.ppt
4-b-tree.ppt
meenamadhuvandhi2
 
Btree
BtreeBtree
Btree
jasscheema
 
Data structures trees - B Tree & B+Tree.pptx
Data structures trees - B Tree & B+Tree.pptxData structures trees - B Tree & B+Tree.pptx
Data structures trees - B Tree & B+Tree.pptx
MalligaarjunanN
 
Adbms 22 dynamic multi level index using b and b+ tree
Adbms 22 dynamic multi level index using b  and b+ treeAdbms 22 dynamic multi level index using b  and b+ tree
Adbms 22 dynamic multi level index using b and b+ tree
Vaibhav Khanna
 
btrees.ppt ttttttttttttttttttttttttttttt
btrees.ppt  tttttttttttttttttttttttttttttbtrees.ppt  ttttttttttttttttttttttttttttt
btrees.ppt ttttttttttttttttttttttttttttt
RAtna29
 
M.E - Computer Science and Engineering-Data structure B tree
M.E - Computer Science and Engineering-Data structure B treeM.E - Computer Science and Engineering-Data structure B tree
M.E - Computer Science and Engineering-Data structure B tree
poonkodiraja2806
 
Ad

More from Krish_ver2 (20)

5.5 back tracking
5.5 back tracking5.5 back tracking
5.5 back tracking
Krish_ver2
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
Krish_ver2
 
5.5 back tracking 02
5.5 back tracking 025.5 back tracking 02
5.5 back tracking 02
Krish_ver2
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructures
Krish_ver2
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructures
Krish_ver2
 
5.4 randamized algorithm
5.4 randamized algorithm5.4 randamized algorithm
5.4 randamized algorithm
Krish_ver2
 
5.3 dynamic programming 03
5.3 dynamic programming 035.3 dynamic programming 03
5.3 dynamic programming 03
Krish_ver2
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programming
Krish_ver2
 
5.3 dyn algo-i
5.3 dyn algo-i5.3 dyn algo-i
5.3 dyn algo-i
Krish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
Krish_ver2
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquer
Krish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
Krish_ver2
 
5.1 greedyyy 02
5.1 greedyyy 025.1 greedyyy 02
5.1 greedyyy 02
Krish_ver2
 
5.1 greedy
5.1 greedy5.1 greedy
5.1 greedy
Krish_ver2
 
5.1 greedy 03
5.1 greedy 035.1 greedy 03
5.1 greedy 03
Krish_ver2
 
4.4 hashing02
4.4 hashing024.4 hashing02
4.4 hashing02
Krish_ver2
 
4.4 hashing
4.4 hashing4.4 hashing
4.4 hashing
Krish_ver2
 
4.4 hashing ext
4.4 hashing  ext4.4 hashing  ext
4.4 hashing ext
Krish_ver2
 
4.4 external hashing
4.4 external hashing4.4 external hashing
4.4 external hashing
Krish_ver2
 
4.2 bst
4.2 bst4.2 bst
4.2 bst
Krish_ver2
 
5.5 back tracking
5.5 back tracking5.5 back tracking
5.5 back tracking
Krish_ver2
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
Krish_ver2
 
5.5 back tracking 02
5.5 back tracking 025.5 back tracking 02
5.5 back tracking 02
Krish_ver2
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructures
Krish_ver2
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructures
Krish_ver2
 
5.4 randamized algorithm
5.4 randamized algorithm5.4 randamized algorithm
5.4 randamized algorithm
Krish_ver2
 
5.3 dynamic programming 03
5.3 dynamic programming 035.3 dynamic programming 03
5.3 dynamic programming 03
Krish_ver2
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programming
Krish_ver2
 
5.3 dyn algo-i
5.3 dyn algo-i5.3 dyn algo-i
5.3 dyn algo-i
Krish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
Krish_ver2
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquer
Krish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
Krish_ver2
 
5.1 greedyyy 02
5.1 greedyyy 025.1 greedyyy 02
5.1 greedyyy 02
Krish_ver2
 
4.4 hashing ext
4.4 hashing  ext4.4 hashing  ext
4.4 hashing ext
Krish_ver2
 
4.4 external hashing
4.4 external hashing4.4 external hashing
4.4 external hashing
Krish_ver2
 
Ad

Recently uploaded (20)

The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 

1.9 b tree

  • 1. Chapter 15 B External Methods – B-Trees
  • 2. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-2 B-Trees • To organize the index file as an external search tree – Use block numbers for child pointers • A child pointer value of –1 is used as the null pointer Figure 15.10a –Figure 15.10a – Blocks organized into a 2-3 tree
  • 3. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-3 B-Trees • If the index file is organized into a 2-3 tree – Each node would contain • Either one or two index records, each of the form <key, pointer> • Three child pointers Figure 15.10b –Figure 15.10b – A single node of the 2-3 tree
  • 4. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-4 B-Trees • An external 2-3 tree is adequate, but an improvement is possible • To improve efficiency – Allow each node to have as many children as possible • In an external environment, the advantage of keeping a search tree short far outweighs the disadvantage of performing extra work at each node • Block size should be the only limiting factor for the number of children
  • 5. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-5 B-Trees • Binary search tree – If a node N has two children, it must contain one key value • 2-3 tree – If a node N has three children, it must contain two key values • General search tree – If a node N has m children, it must contain m – 1 key values
  • 6. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-6 B-Trees Figure 15.11Figure 15.11 a) A node with two children; b) a node with three children; c) a node with m children
  • 7. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-7 B-Trees • B-tree of degree m – All leaves are at the same level – Nodes • Each node contains between m – 1 and m/2 records • Each internal node has one more child than it has records • Exception: The root can contain as few as one record and can have as few as two children – Example • A 2-3 tree is a B-tree of degree 3 – Each node contains between (3-1) = 2 and 3/2 = 1 records.
  • 8. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-8 B-Trees Figure 15.13Figure 15.13 A B-tree of degree 5
  • 9. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-9 B-Trees • Retrieval – Generalized search tree retrieval • Insertion into a B-tree – Step 1: Insert the data record into the data file – Step 2: Insert a corresponding index record into the index file
  • 10. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-10 B-Trees Figure 15.14a and bFigure 15.14a and b The steps for inserting 55
  • 11. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-11 B-Trees Figure 15.14c-eFigure 15.14c-e The steps for inserting 55
  • 12. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-12 B-Trees • Deletion from a B-tree – Step 1: Locate the index record in the index file and delete it from the index file – Step 2: Delete the data record from the data file
  • 13. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-13 B-Trees Figure 15.15a and bFigure 15.15a and b The steps for deleting 73
  • 14. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-14 B-Trees Figure 15.15cFigure 15.15c The steps for deleting 73
  • 15. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-15 B-Trees Figure 15.15dFigure 15.15d The steps for deleting 73
  • 16. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-16 B-Trees Figure 14.15e and fFigure 14.15e and f The steps for deleting 73
  • 17. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-17 Traversals • Accessing only the search key of each record, not the data file – Not efficiently supported by the hashing implementation – Efficiently supported by the B-tree implementation • The search keys can be visited in sorted order by using an inorder traversal of the B-tree • Accessing the entire data record – Not efficiently supported by the B-tree implementation
  • 18. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-18 Multiple Indexing • Advantage – Allows multiple data organizations • Disadvantage – More storage space – Additional overhead for updating each index whenever the data file is modified
  • 19. © 2004 Pearson Addison-Wesley. All rights reserved 15 B-19 Multiple Indexing Figure 15.16Figure 15.16 Multiple index files
  • 20. Chi-Cheng Lin, Winona State University 20 Variations of B-Trees • The fewer nodes are in a B-tree, the better. (Why?) • Problems of B-tree: – It could be only half full • More nodes required • Space wasted – Inorder traversal “jumps” around nodes • B* -Trees: introduced by Donald Knuth • B+ -Trees: introduced by H. Wedekind
  • 21. Chi-Cheng Lin, Winona State University 21 B* -Trees • B* -tree of degree m – All leaves are at the same level – Nodes • Each node contains between m – 1 and (2m – 1)/3 records • Each internal node has one more child than it has records • Exception: The root can contain as few as one record and as many as (2m-2) children – Example • B* -tree of degree 9 – Each node contains between (9 – 1) = 8 and (2×9 – 1)/3 = 5 records.
  • 22. Chi-Cheng Lin, Winona State University 22 B* -Trees • Splitting nodes – When a node overflows, it is not split right away – A split is delayed by redistributing the keys between a node and its sibling – When both a node and its sibling are full, an insertion to the node will split the two nodes into three nodes • A B*-Tree is always two-third full instead of half full  number of nodes in the tree is reduced
  • 23. Chi-Cheng Lin, Winona State University 23 B* -Trees
  • 24. Chi-Cheng Lin, Winona State University 24 B+ -Trees • References to data are only made from the leaves – All index records can be found from the leaves • Two sets of nodes – Index set • Internal nodes • Provides fast access of data – Sequence set • Leaves, linked sequentially • Provides efficient inorder traversal
  • 25. Chi-Cheng Lin, Winona State University 25 B+ -Trees