SlideShare a Scribd company logo
B+ Tree By Li Wen CS157B Professor: Sin-Min Lee What is a B+ Tree Searching Insertion Deletion
What is a B+ Tree Definition and benefits of a B+Tree 1.Definition: A B+tree is a balanced tree in which every path from the root of the tree to a leaf is of the same length, and each nonleaf node of the tree has between [n/2] and [n] children, where n is fixed for a particular tree. It contains index pages and data pages. The capacity of a leaf has to be 50% or more. For example: if n = 4, then the key for each node is between 2 to 4. The index page will be 4 + 1 = 5.  Example of a B+ tree with four keys (n = 4) looks like this:
What is a B+ Tree
What is a B+ Tree Question: Is this a valid B+ Tree? C  E A  B  C D  E F  G  H
What is a B+ Tree Answer:  1.Both tree in slide 3 and slide 4 are valid; how you store data in B+ Tree depend on your algorithm when it is implemented.  2.As long as the number of data in each leaf are balanced, it doesn’t matter how many data you stored in the leaves. For example: in the previous question, the n can be 3 or 4, but can not be 5 or more than 5.
What is a B+ Tree  Benefit: Every data structure has it’s benefit to solve a particular problem over other data structures.  The two main benefits of B+ tree are: Based on it’s definition, it is easy to maintain it’s balance. For example: Do you have to check your B+ tree’s balance after you edit it? No, because all B+ trees are inherently balanced, which make it easy for us to manipulate the data.
What is a B+ Tree 2.The searching time in a B+ tree is much shorter than most of other kinds of trees. For example: To search a data in one million key-values, a balanced binary requires about 20 block reads, in contrast only 4 block reads is required in B+ Tree.  (The formula to calculate searching time can be found in the book. Page 492-493)
Searching Since no structure change in a B+ tree during a searching process, so just compare the key value with the data in the tree, then give the result back.  For example: find the value  45 , and  15  in below tree.
Searching Result:  1. For the value of 45, not found. 2. For the value of 15, return the position where the pointer located.
Insertion Since insert a value into a B+ tree may cause the tree unbalance, so rearrange the tree if needed. Example #1: insert  28  into the below tree. 25  28   30  Dose not violates the 50% rule
Insertion Result:
Insertion Example #2: insert  70  into below tree
Insertion Process: split the tree 50  55  60  65  70   50  55 60  65  70   Violate the 50% rule, split the leaf
Insertion Result: chose the middle key 60, and place it in the index page between 50 and 75.
Insertion The insert algorithm for B+ Tree Split the leaf page.  Records with keys < middle key go to the left leaf page.  Records with keys >= middle key go to the right leaf page.  Split the index page.  Keys < middle key go to the left index page.  Keys > middle key go to the right index page.  The middle key goes to the next (higher level) index.  IF the next level index page is full, continue splitting the index pages.  YES  YES  Split the leaf page  Place Middle Key in the index page in sorted order.  Left leaf page contains records with keys below the middle key.  Right leaf page contains records with keys equal to or greater than the middle key.  NO  YES  Place the record in sorted position in the appropriate leaf page  NO  NO  Action  Index Page Full  Data Page Full
Insertion Exercise: add a key value  95  to the below tree.  75  80  85   90  95   25  50  60  75  85   75  80 85  90  95 Violate the 50% rule, split the leaf.
Insertion Result: again put the middle key 60 to the index page and rearrange the tree.
Deletion Same as insertion, the tree has to be rebuild if the deletion result violate the rule of B+ tree. Example #1: delete  70  from the tree 60  65  This is OK.
Deletion Result:
Deletion Example #2: delete  25  from below tree, but  25  appears in the index page. 28  30  But… This is OK.
Deletion Result: replace  28  in the index page. Add 28
Deletion Example #3: delete  60  from the below tree 65  50  55  65  Violet the 50% rule
Deletion Result: delete 60 from the index page and combine the rest of index pages.
Deletion Delete algorithm for B+ trees Combine the leaf page and its sibling.  Adjust the index page to reflect the change.  Combine the index page with its sibling.  Continue combining index pages until you reach a page with the correct fill factor or you reach the root page.  YES  YES  Combine the leaf page and its sibling. Change the index page to reflect the change.  NO  YES  Delete the record from the leaf page. Arrange keys in ascending order to fill void. If the key of the deleted record appears in the index page, use the next key to replace it.  NO  NO  Action  Index Page Below Fill Factor  Data Page Below Fill Factor
Conclusion For a B+ Tree: It is easy to maintain it’s balance. The searching time is short than most of other types of trees.
Reference http://babbage.clarku.edu/~achou/cs160/B+Trees/B+Trees.htm www.csee.umbc.edu/~pmundur/courses/CMSC461-05/ch12.ppt
Ad

More Related Content

What's hot (20)

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
HAMID-50
 
B+tree Data structures presentation
B+tree Data structures presentationB+tree Data structures presentation
B+tree Data structures presentation
Muhammad Bilal Khan
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)
Home
 
B trees dbms
B trees dbmsB trees dbms
B trees dbms
kuldeep100
 
B+ Tree
B+ TreeB+ Tree
B+ Tree
Mujahid Hussain Jalbani
 
DMBS Indexes.pptx
DMBS Indexes.pptxDMBS Indexes.pptx
DMBS Indexes.pptx
husainsadikarvy
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
koolkampus
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
Dr Sandeep Kumar Poonia
 
single linked list
single linked listsingle linked list
single linked list
Sathasivam Rangasamy
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
somendra kumar
 
B tree
B treeB tree
B tree
Tech_MX
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
khabbab_h
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
Anuj Modi
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
sagar yadav
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
Hitesh Mohapatra
 
Tree and graph
Tree and graphTree and graph
Tree and graph
Muhaiminul Islam
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
Dhananjaysinh Jhala
 
linked list
linked list linked list
linked list
Mohaimin Rahat
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Muhammad Hammad Waseem
 
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
HAMID-50
 
B+tree Data structures presentation
B+tree Data structures presentationB+tree Data structures presentation
B+tree Data structures presentation
Muhammad Bilal Khan
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)
Home
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
koolkampus
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
somendra kumar
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
khabbab_h
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
Anuj Modi
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
sagar yadav
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Muhammad Hammad Waseem
 

Similar to b+ tree (20)

B+tree
B+treeB+tree
B+tree
jasscheema
 
Nikhat b+ trees ppt
Nikhat b+ trees pptNikhat b+ trees ppt
Nikhat b+ trees ppt
Nikihat Maniyar
 
Best for b trees
Best for b treesBest for b trees
Best for b trees
DineshRaaja
 
Free video lectures for mba
Free video lectures for mbaFree video lectures for mba
Free video lectures for mba
Edhole.com
 
Free video lectures for mba
Free video lectures for mbaFree video lectures for mba
Free video lectures for mba
Edhole.com
 
B Trees and B+ Trees Data structures in Computer Sciences
B Trees and B+ Trees Data structures in Computer SciencesB Trees and B+ Trees Data structures in Computer Sciences
B Trees and B+ Trees Data structures in Computer Sciences
Tanmay Kataria
 
B+ trees and height balance tree
B+ trees and height balance treeB+ trees and height balance tree
B+ trees and height balance tree
Jasleen Kaur (Chandigarh University)
 
Excel-2016-L1-PPT.pptx
Excel-2016-L1-PPT.pptxExcel-2016-L1-PPT.pptx
Excel-2016-L1-PPT.pptx
macelclavero
 
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
MathkeBhoot
 
B+ Tree
B+ TreeB+ Tree
B+ Tree
cesarpa
 
MS Excel new version 2013
MS Excel new version 2013MS Excel new version 2013
MS Excel new version 2013
AmirAshfaq
 
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
SadiaSharmin40
 
My excel reviewer_2
My excel reviewer_2My excel reviewer_2
My excel reviewer_2
Donelle Agudo
 
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
 
My excel reviewer
My excel reviewerMy excel reviewer
My excel reviewer
Donelle Agudo
 
17Abstract[Dissertation Title]by[your official name]
17Abstract[Dissertation Title]by[your official name]17Abstract[Dissertation Title]by[your official name]
17Abstract[Dissertation Title]by[your official name]
AnastaciaShadelb
 
IGCSE ICT (0417/0983) - Spreadsheets - Ajiro Tech
IGCSE ICT (0417/0983) - Spreadsheets - Ajiro TechIGCSE ICT (0417/0983) - Spreadsheets - Ajiro Tech
IGCSE ICT (0417/0983) - Spreadsheets - Ajiro Tech
Ajiro Ndi
 
CHAPTER 5 TREE Student.pptxlllllllllllllllllllllllllll
CHAPTER 5 TREE Student.pptxlllllllllllllllllllllllllllCHAPTER 5 TREE Student.pptxlllllllllllllllllllllllllll
CHAPTER 5 TREE Student.pptxlllllllllllllllllllllllllll
rajinevitable05
 
Tabulation
TabulationTabulation
Tabulation
freelancer
 
Data Structures using Python(generic elective).pptx
Data Structures using Python(generic elective).pptxData Structures using Python(generic elective).pptx
Data Structures using Python(generic elective).pptx
mastimajakDKS
 
Best for b trees
Best for b treesBest for b trees
Best for b trees
DineshRaaja
 
Free video lectures for mba
Free video lectures for mbaFree video lectures for mba
Free video lectures for mba
Edhole.com
 
Free video lectures for mba
Free video lectures for mbaFree video lectures for mba
Free video lectures for mba
Edhole.com
 
B Trees and B+ Trees Data structures in Computer Sciences
B Trees and B+ Trees Data structures in Computer SciencesB Trees and B+ Trees Data structures in Computer Sciences
B Trees and B+ Trees Data structures in Computer Sciences
Tanmay Kataria
 
Excel-2016-L1-PPT.pptx
Excel-2016-L1-PPT.pptxExcel-2016-L1-PPT.pptx
Excel-2016-L1-PPT.pptx
macelclavero
 
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
MathkeBhoot
 
MS Excel new version 2013
MS Excel new version 2013MS Excel new version 2013
MS Excel new version 2013
AmirAshfaq
 
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
SadiaSharmin40
 
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
 
17Abstract[Dissertation Title]by[your official name]
17Abstract[Dissertation Title]by[your official name]17Abstract[Dissertation Title]by[your official name]
17Abstract[Dissertation Title]by[your official name]
AnastaciaShadelb
 
IGCSE ICT (0417/0983) - Spreadsheets - Ajiro Tech
IGCSE ICT (0417/0983) - Spreadsheets - Ajiro TechIGCSE ICT (0417/0983) - Spreadsheets - Ajiro Tech
IGCSE ICT (0417/0983) - Spreadsheets - Ajiro Tech
Ajiro Ndi
 
CHAPTER 5 TREE Student.pptxlllllllllllllllllllllllllll
CHAPTER 5 TREE Student.pptxlllllllllllllllllllllllllllCHAPTER 5 TREE Student.pptxlllllllllllllllllllllllllll
CHAPTER 5 TREE Student.pptxlllllllllllllllllllllllllll
rajinevitable05
 
Data Structures using Python(generic elective).pptx
Data Structures using Python(generic elective).pptxData Structures using Python(generic elective).pptx
Data Structures using Python(generic elective).pptx
mastimajakDKS
 
Ad

Recently uploaded (20)

Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Ad

b+ tree

  • 1. B+ Tree By Li Wen CS157B Professor: Sin-Min Lee What is a B+ Tree Searching Insertion Deletion
  • 2. What is a B+ Tree Definition and benefits of a B+Tree 1.Definition: A B+tree is a balanced tree in which every path from the root of the tree to a leaf is of the same length, and each nonleaf node of the tree has between [n/2] and [n] children, where n is fixed for a particular tree. It contains index pages and data pages. The capacity of a leaf has to be 50% or more. For example: if n = 4, then the key for each node is between 2 to 4. The index page will be 4 + 1 = 5. Example of a B+ tree with four keys (n = 4) looks like this:
  • 3. What is a B+ Tree
  • 4. What is a B+ Tree Question: Is this a valid B+ Tree? C E A B C D E F G H
  • 5. What is a B+ Tree Answer: 1.Both tree in slide 3 and slide 4 are valid; how you store data in B+ Tree depend on your algorithm when it is implemented. 2.As long as the number of data in each leaf are balanced, it doesn’t matter how many data you stored in the leaves. For example: in the previous question, the n can be 3 or 4, but can not be 5 or more than 5.
  • 6. What is a B+ Tree Benefit: Every data structure has it’s benefit to solve a particular problem over other data structures. The two main benefits of B+ tree are: Based on it’s definition, it is easy to maintain it’s balance. For example: Do you have to check your B+ tree’s balance after you edit it? No, because all B+ trees are inherently balanced, which make it easy for us to manipulate the data.
  • 7. What is a B+ Tree 2.The searching time in a B+ tree is much shorter than most of other kinds of trees. For example: To search a data in one million key-values, a balanced binary requires about 20 block reads, in contrast only 4 block reads is required in B+ Tree. (The formula to calculate searching time can be found in the book. Page 492-493)
  • 8. Searching Since no structure change in a B+ tree during a searching process, so just compare the key value with the data in the tree, then give the result back. For example: find the value 45 , and 15 in below tree.
  • 9. Searching Result: 1. For the value of 45, not found. 2. For the value of 15, return the position where the pointer located.
  • 10. Insertion Since insert a value into a B+ tree may cause the tree unbalance, so rearrange the tree if needed. Example #1: insert 28 into the below tree. 25 28 30 Dose not violates the 50% rule
  • 12. Insertion Example #2: insert 70 into below tree
  • 13. Insertion Process: split the tree 50 55 60 65 70 50 55 60 65 70 Violate the 50% rule, split the leaf
  • 14. Insertion Result: chose the middle key 60, and place it in the index page between 50 and 75.
  • 15. Insertion The insert algorithm for B+ Tree Split the leaf page. Records with keys < middle key go to the left leaf page. Records with keys >= middle key go to the right leaf page. Split the index page. Keys < middle key go to the left index page. Keys > middle key go to the right index page. The middle key goes to the next (higher level) index. IF the next level index page is full, continue splitting the index pages. YES YES Split the leaf page Place Middle Key in the index page in sorted order. Left leaf page contains records with keys below the middle key. Right leaf page contains records with keys equal to or greater than the middle key. NO YES Place the record in sorted position in the appropriate leaf page NO NO Action Index Page Full Data Page Full
  • 16. Insertion Exercise: add a key value 95 to the below tree. 75 80 85 90 95 25 50 60 75 85 75 80 85 90 95 Violate the 50% rule, split the leaf.
  • 17. Insertion Result: again put the middle key 60 to the index page and rearrange the tree.
  • 18. Deletion Same as insertion, the tree has to be rebuild if the deletion result violate the rule of B+ tree. Example #1: delete 70 from the tree 60 65 This is OK.
  • 20. Deletion Example #2: delete 25 from below tree, but 25 appears in the index page. 28 30 But… This is OK.
  • 21. Deletion Result: replace 28 in the index page. Add 28
  • 22. Deletion Example #3: delete 60 from the below tree 65 50 55 65 Violet the 50% rule
  • 23. Deletion Result: delete 60 from the index page and combine the rest of index pages.
  • 24. Deletion Delete algorithm for B+ trees Combine the leaf page and its sibling. Adjust the index page to reflect the change. Combine the index page with its sibling. Continue combining index pages until you reach a page with the correct fill factor or you reach the root page. YES YES Combine the leaf page and its sibling. Change the index page to reflect the change. NO YES Delete the record from the leaf page. Arrange keys in ascending order to fill void. If the key of the deleted record appears in the index page, use the next key to replace it. NO NO Action Index Page Below Fill Factor Data Page Below Fill Factor
  • 25. Conclusion For a B+ Tree: It is easy to maintain it’s balance. The searching time is short than most of other types of trees.
  翻译: