SlideShare a Scribd company logo
1 of 32
B-Trees
Motivation for B-Trees ,[object Object],[object Object],[object Object],[object Object],[object Object]
Motivation (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Motivation (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Definition of a B-tree ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
An example B-Tree 51 62 42 6 12 26 55 60 70 64 90 45 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
[object Object],[object Object],[object Object],[object Object],[object Object],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 14 6 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 28 1 2 6 7, 52, 16, 48 get added to the leaf nodes 8 17 12 14 25 28 1 2 6 16 48 52 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 68 25 26 28 29 1 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 68 25 26 29 45
Inserting into a B-Tree ,[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise in Inserting a B-Tree  ,[object Object],[object Object],[object Object]
Removal from a B-tree ,[object Object],[object Object],[object Object]
Removal from a B-tree (2) ,[object Object],[object Object],[object Object]
Type #1: Simple leaf deletion Delete 2:  Since there are enough keys in the node, just delete it Assuming a 5-way B-Tree, as before... Note when printed: this slide is animated 12 29 52 2 7 9 15 22 56 69 72 31 43
Type #2: Simple non-leaf deletion Delete 52 Borrow the predecessor or (in this case) successor 56 Note when printed: this slide is animated 12 29 52 7 9 15 22 56 69 72 31 43
Type #4: Too few keys in node and its siblings Delete 72 Too few keys! Note when printed: this slide is animated 12 29 56 7 9 15 22 69 72 31 43 Join back together
Type #4: Too few keys in node and its siblings Note when printed: this slide is animated 12 29 7 9 15 22 69 56 31 43
Type #3: Enough siblings Delete 22 Note when printed: this slide is animated 12 29 7 9 15 22 69 56 31 43 Demote root key and promote leaf key
Type #3: Enough siblings 12 29 7 9 15 31 Note when printed: this slide is animated 69 56 43
Exercise in Removal from a B-Tree ,[object Object],[object Object],[object Object],[object Object],[object Object]
Analysis of B-Trees ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Reasons for using B-Trees ,[object Object],[object Object],[object Object],[object Object],[object Object]
Comparing Trees ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementing an ADT ,[object Object]
Example: Implementing a B-Tree ,[object Object],[object Object],[object Object]
1 - What classes are required? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2 - What are the class interactions? B-Tree BNode BKey Record (Comparable) recursive 1  N 1  1
3 - What are the algorithms? ,[object Object],[object Object]
4 - What data struct’s are required? ,[object Object],[object Object],[object Object],[object Object]
5 - What methods are required? ,[object Object],[object Object],[object Object]

More Related Content

What's hot (20)

B+ Tree
B+ TreeB+ Tree
B+ Tree
 
Nikhat b+ trees ppt
Nikhat b+ trees pptNikhat b+ trees ppt
Nikhat b+ trees ppt
 
B tree
B treeB tree
B tree
 
B Trees
B TreesB Trees
B Trees
 
trees
trees trees
trees
 
B+ tree intro,uses,insertion and deletion
B+ tree intro,uses,insertion and deletionB+ tree intro,uses,insertion and deletion
B+ tree intro,uses,insertion and deletion
 
B+ tree
B+ treeB+ tree
B+ tree
 
B+ Tree
B+ TreeB+ Tree
B+ Tree
 
B+ trees and height balance tree
B+ trees and height balance treeB+ trees and height balance tree
B+ trees and height balance tree
 
Binary tree
Binary tree Binary tree
Binary tree
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Trees
TreesTrees
Trees
 
Data structure tree- advance
Data structure tree- advanceData structure tree- advance
Data structure tree- advance
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Binary Search Tree (BST)
Binary Search Tree (BST)Binary Search Tree (BST)
Binary Search Tree (BST)
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
Data structure tree - beginner
Data structure tree - beginnerData structure tree - beginner
Data structure tree - beginner
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
 

Similar to 08 B Trees

B tree by-jash acharya
B tree by-jash acharyaB tree by-jash acharya
B tree by-jash acharyaJash Acharya
 
BTrees-fall2010.ppt
BTrees-fall2010.pptBTrees-fall2010.ppt
BTrees-fall2010.pptzalanmvb
 
Presentation on b trees [autosaved]
Presentation on b trees [autosaved]Presentation on b trees [autosaved]
Presentation on b trees [autosaved]AKASHKUMAR1542
 
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.pptxMalligaarjunanN
 
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 structureSadiaSharmin40
 
B TREE ( a to z concept ) in data structure or DBMS
B TREE ( a to z concept ) in data structure  or DBMSB TREE ( a to z concept ) in data structure  or DBMS
B TREE ( a to z concept ) in data structure or DBMSMathkeBhoot
 
btree.ppt ggggggggggggggggggggggggggggggg
btree.ppt gggggggggggggggggggggggggggggggbtree.ppt ggggggggggggggggggggggggggggggg
btree.ppt gggggggggggggggggggggggggggggggRAtna29
 
presentation on b tress. heap trees.hashing
presentation on b tress. heap trees.hashingpresentation on b tress. heap trees.hashing
presentation on b tress. heap trees.hashingBindiya syed
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data StructureAnuj Modi
 
Indexing.ppt mmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Indexing.ppt mmmmmmmmmmmmmmmmmmmmmmmmmmmmmIndexing.ppt mmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Indexing.ppt mmmmmmmmmmmmmmmmmmmmmmmmmmmmmRAtna29
 

Similar to 08 B Trees (20)

B tree by-jash acharya
B tree by-jash acharyaB tree by-jash acharya
B tree by-jash acharya
 
B trees
B treesB trees
B trees
 
Btree
BtreeBtree
Btree
 
BTrees-fall2010.ppt
BTrees-fall2010.pptBTrees-fall2010.ppt
BTrees-fall2010.ppt
 
Presentation on b trees [autosaved]
Presentation on b trees [autosaved]Presentation on b trees [autosaved]
Presentation on b trees [autosaved]
 
B trees2
B trees2B trees2
B trees2
 
Btrees
BtreesBtrees
Btrees
 
B trees
B treesB trees
B trees
 
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
 
Multi way&btree
Multi way&btreeMulti way&btree
Multi way&btree
 
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
 
B TREE ( a to z concept ) in data structure or DBMS
B TREE ( a to z concept ) in data structure  or DBMSB TREE ( a to z concept ) in data structure  or DBMS
B TREE ( a to z concept ) in data structure or DBMS
 
4-b-tree.ppt
4-b-tree.ppt4-b-tree.ppt
4-b-tree.ppt
 
B trees
B treesB trees
B trees
 
B+ tree.pptx
B+ tree.pptxB+ tree.pptx
B+ tree.pptx
 
btree.ppt ggggggggggggggggggggggggggggggg
btree.ppt gggggggggggggggggggggggggggggggbtree.ppt ggggggggggggggggggggggggggggggg
btree.ppt ggggggggggggggggggggggggggggggg
 
presentation on b tress. heap trees.hashing
presentation on b tress. heap trees.hashingpresentation on b tress. heap trees.hashing
presentation on b tress. heap trees.hashing
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 
Indexing.ppt
Indexing.pptIndexing.ppt
Indexing.ppt
 
Indexing.ppt mmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Indexing.ppt mmmmmmmmmmmmmmmmmmmmmmmmmmmmmIndexing.ppt mmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Indexing.ppt mmmmmmmmmmmmmmmmmmmmmmmmmmmmm
 

Recently uploaded

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Recently uploaded (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

08 B Trees

  • 2.
  • 3.
  • 4.
  • 5.
  • 6. An example B-Tree 51 62 42 6 12 26 55 60 70 64 90 45 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
  • 7.
  • 8. Constructing a B-tree (contd.) 1 2 8 12 25 6, 14, 28 get added to the leaf nodes: 1 2 8 12 14 6 25 28
  • 9. 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 28 1 2 6 7, 52, 16, 48 get added to the leaf nodes 8 17 12 14 25 28 1 2 6 16 48 52 7
  • 10. 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 68 25 26 28 29 1 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
  • 11. Constructing a B-tree (contd.) 17 3 8 28 48 1 2 6 7 12 14 16 52 53 55 68 25 26 29 45
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Type #1: Simple leaf deletion Delete 2: Since there are enough keys in the node, just delete it Assuming a 5-way B-Tree, as before... Note when printed: this slide is animated 12 29 52 2 7 9 15 22 56 69 72 31 43
  • 17. Type #2: Simple non-leaf deletion Delete 52 Borrow the predecessor or (in this case) successor 56 Note when printed: this slide is animated 12 29 52 7 9 15 22 56 69 72 31 43
  • 18. Type #4: Too few keys in node and its siblings Delete 72 Too few keys! Note when printed: this slide is animated 12 29 56 7 9 15 22 69 72 31 43 Join back together
  • 19. Type #4: Too few keys in node and its siblings Note when printed: this slide is animated 12 29 7 9 15 22 69 56 31 43
  • 20. Type #3: Enough siblings Delete 22 Note when printed: this slide is animated 12 29 7 9 15 22 69 56 31 43 Demote root key and promote leaf key
  • 21. Type #3: Enough siblings 12 29 7 9 15 31 Note when printed: this slide is animated 69 56 43
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. 2 - What are the class interactions? B-Tree BNode BKey Record (Comparable) recursive 1 N 1 1
  • 30.
  • 31.
  • 32.