SlideShare a Scribd company logo
B+-Trees
Preethi B
Department of Computer
Science
Coimbatore -43
B+ TREE
• A B+ tree is an n-array tree with a variable
but often large number of children per node.
• A B+ tree consists of a root, internal nodes
and leaves.
• The root may be either a leaf or a node with
two or more children.
• The primary value of a B+ tree is in storing
data for efficient retrieval in a block-oriented
storage context — in particular, file systems.
Example Tree Index
• Index entries:<search key value, page id> they
direct search for data entries in leaves.
• Example where each node can hold 2 entries;
10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97*
20 33 51 63
40
Root
ISAM
(Indexed Sequential Access Method)
48*
10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63*
20 33 51 63
40
97*
Root
Overflow
Pages
Leaf
Pages
Primary
23* 41*
42*
Index
Pages
Example B+ Tree
• Search begins at root, and key comparisons direct it to a
leaf.
• Search for 5*, 15*, all data entries >= 24* ...
Based on the search for 15*, we know it is not in the tree!
Root
17 24 30
2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39*
13
B+ Tree - Properties
• Balanced
• Every node except root must be at least ½ full.
• Order: the minimum number of keys/pointers in
a non-leaf node
• Fanout of a node: the number of pointers out of
the node
B+ Trees in Practice
• Typical order: 100. Typical fill-factor: 67%.
– average fanout = 133
• Typical capacities:
– Height 3: 1333
= 2,352,637 entries
– Height 4: 1334
= 312,900,700 entries
• Can often hold top levels in buffer pool:
– Level 1 = 1 page = 8 Kbytes
– Level 2 = 133 pages = 1 Mbyte
– Level 3 = 17,689 pages = 133 MBytes
B+ Trees: Summary
• Searching:
– logd(n) – Where d is the order, and n is the number of entries
• Insertion:
– Find the leaf to insert into
– If full, split the node, and adjust index accordingly
– Similar cost as searching
• Deletion
– Find the leaf node
– Delete
– May not remain half-full; must adjust the index accordingly
Insert 23*
Root
17 24 30
2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39*
13
Root
17 24 30
2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39*
13
23*
No splitting required.
Example B+ Tree - Inserting 8*
Notice that root was split, leading to increase in height.
In this example, we can avoid split by re-distributing
entries; however, this is usually not done in practice.
Root
17 24 30
2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39*
13
2* 3*
Root
17
24 30
14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39*
135
7*5* 8*
Data vs. Index Page Split
(from previous example of inserting “8”)
• Observe how
minimum
occupancy is
guaranteed in both
leaf and index pg
splits.
• Note difference
between copy-up
and push-up; be
sure you
understand the
reasons for this.
2* 3* 5* 7*
5
Entry to be inserted in parent node.
(Note that 5 is
continues to appear in the leaf.)
s copied up and
2* 3* 5* 7* 8* …
Data
Page
Split
8*
5 24 3013
appears once in the index. Contrast17
Entry to be inserted in parent node.
(Note that 17 is pushed up and only
this with a leaf split.)
17 24 3013Index
Page
Split
5
Root
17 24 30
2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39*
13
2* 3*
Root
17
24 30
14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39*
135
7*5* 8*
Delete 19*
2* 3*
Root
17
24 30
14* 16* 20* 22* 24* 27* 29* 33* 34* 38* 39*
135
7*5* 8*
Delete 20* ...
2* 3*
Root
17
24 30
14* 16* 20* 22* 24* 27* 29* 33* 34* 38* 39*
135
7*5* 8*
2* 3*
Root
17
27 30
14* 16* 22* 24* 27* 29* 33* 34* 38* 39*
135
7*5* 8*
Delete 19* and 20* ...
• Deleting 19* is easy.
• Deleting 20* is done with re-distribution. Notice how
middle key is copied up.
• Further deleting 24* results in more drastic changes
Delete 24* ...
2* 3*
Root
17
27 30
14* 16* 22* 24* 27* 29* 33* 34* 38* 39*
135
7*5* 8*
2* 3*
Root
17
27 30
14* 16* 22* 27* 29* 33* 34* 38* 39*
135
7*5* 8*
No redistribution from
neighbors possible
Deleting 24*
• Must merge.
• Observe `toss’ of index entry
(on right), and `pull down’ of
index entry (below).
30
22* 27* 29* 33* 34* 38* 39*
2* 3* 7* 14* 16* 22* 27* 29* 33* 34* 38* 39*5* 8*
Root
30135 17
References:
http://www.di.ufpb.br/lucidio/Btrees.pdf
https://www.sci.unich.it/~acciaro/bpiutrees.pdf

More Related Content

What's hot

Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
ghhgj jhgh
 
10 Red-Black Trees
10 Red-Black Trees10 Red-Black Trees
10 Red-Black Trees
Andres Mendez-Vazquez
 
Mis 582 exam
Mis 582 examMis 582 exam
Mis 582 exam
JenniferBall47
 
Binary tree
Binary tree Binary tree
Binary tree
Rajendran
 
Red Black Tree
Red Black TreeRed Black Tree
Daa unit 2
Daa unit 2Daa unit 2
Daa unit 2
Abhimanyu Mishra
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
Daniyal Khan
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
Zaid Shabbir
 
Lec14
Lec14Lec14
7th math c2 -inv#4
7th math c2 -inv#47th math c2 -inv#4
7th math c2 -inv#4
jdurst65
 
Red black trees
Red black treesRed black trees
Red black trees
Maira Shahnawaz
 
7.tree
7.tree7.tree
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
Dhrumil Panchal
 
Normalization in SQL | Edureka
Normalization in SQL | EdurekaNormalization in SQL | Edureka
Normalization in SQL | Edureka
Edureka!
 
Lec13
Lec13Lec13
Red Black Trees
Red Black TreesRed Black Trees
Red Black Trees
Varun Mahajan
 
Red black tree
Red black treeRed black tree
Red black tree
qamar mustafa
 
Red black trees
Red black treesRed black trees
Red black trees
mumairsadiq
 
THREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREETHREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREE
Siddhi Shrivas
 
Binary tree
Binary treeBinary tree
Binary tree
Rajendran
 

What's hot (20)

Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
10 Red-Black Trees
10 Red-Black Trees10 Red-Black Trees
10 Red-Black Trees
 
Mis 582 exam
Mis 582 examMis 582 exam
Mis 582 exam
 
Binary tree
Binary tree Binary tree
Binary tree
 
Red Black Tree
Red Black TreeRed Black Tree
Red Black Tree
 
Daa unit 2
Daa unit 2Daa unit 2
Daa unit 2
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 
Lec14
Lec14Lec14
Lec14
 
7th math c2 -inv#4
7th math c2 -inv#47th math c2 -inv#4
7th math c2 -inv#4
 
Red black trees
Red black treesRed black trees
Red black trees
 
7.tree
7.tree7.tree
7.tree
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
Normalization in SQL | Edureka
Normalization in SQL | EdurekaNormalization in SQL | Edureka
Normalization in SQL | Edureka
 
Lec13
Lec13Lec13
Lec13
 
Red Black Trees
Red Black TreesRed Black Trees
Red Black Trees
 
Red black tree
Red black treeRed black tree
Red black tree
 
Red black trees
Red black treesRed black trees
Red black trees
 
THREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREETHREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREE
 
Binary tree
Binary treeBinary tree
Binary tree
 

Similar to B+ tree

btree.ppt ggggggggggggggggggggggggggggggg
btree.ppt gggggggggggggggggggggggggggggggbtree.ppt ggggggggggggggggggggggggggggggg
btree.ppt ggggggggggggggggggggggggggggggg
RAtna29
 
btrees.ppt ttttttttttttttttttttttttttttt
btrees.ppt  tttttttttttttttttttttttttttttbtrees.ppt  ttttttttttttttttttttttttttttt
btrees.ppt ttttttttttttttttttttttttttttt
RAtna29
 
B+ trees
B+ treesB+ trees
B+ trees
Anitha Rani
 
B+ tree.pptx
B+ tree.pptxB+ tree.pptx
B+ tree.pptx
Maitri Shah
 
Presentation on b trees [autosaved]
Presentation on b trees [autosaved]Presentation on b trees [autosaved]
Presentation on b trees [autosaved]
AKASHKUMAR1542
 
B trees
B treesB trees
BTrees - Great alternative to Red Black, AVL and other BSTs
BTrees - Great alternative to Red Black, AVL and other BSTsBTrees - Great alternative to Red Black, AVL and other BSTs
BTrees - Great alternative to Red Black, AVL and other BSTs
Amrinder Arora
 
B+tree Data structures presentation
B+tree Data structures presentationB+tree Data structures presentation
B+tree Data structures presentation
Muhammad Bilal Khan
 
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
 
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
 
2-3 Tree, Everything you need to know
2-3 Tree,  Everything you need to know2-3 Tree,  Everything you need to know
2-3 Tree, Everything you need to know
Littbarski Santos
 
Modern Database Systems - Lecture 02
Modern Database Systems - Lecture 02Modern Database Systems - Lecture 02
Modern Database Systems - Lecture 02
Michael Mathioudakis
 
LEC 7-DS ALGO(expression and huffman).pdf
LEC 7-DS  ALGO(expression and huffman).pdfLEC 7-DS  ALGO(expression and huffman).pdf
LEC 7-DS ALGO(expression and huffman).pdf
MuhammadUmerIhtisham
 
Binary tree
Binary treeBinary tree
Binary tree
Maria Saleem
 
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
 
08 B Trees
08 B Trees08 B Trees
08 B Trees
guestf7d226
 
A41001011
A41001011A41001011
A41001011
ijceronline
 
[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing
AnusAhmad
 
B trees
B treesB trees
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
INAM352782
 

Similar to B+ tree (20)

btree.ppt ggggggggggggggggggggggggggggggg
btree.ppt gggggggggggggggggggggggggggggggbtree.ppt ggggggggggggggggggggggggggggggg
btree.ppt ggggggggggggggggggggggggggggggg
 
btrees.ppt ttttttttttttttttttttttttttttt
btrees.ppt  tttttttttttttttttttttttttttttbtrees.ppt  ttttttttttttttttttttttttttttt
btrees.ppt ttttttttttttttttttttttttttttt
 
B+ trees
B+ treesB+ trees
B+ trees
 
B+ tree.pptx
B+ tree.pptxB+ tree.pptx
B+ tree.pptx
 
Presentation on b trees [autosaved]
Presentation on b trees [autosaved]Presentation on b trees [autosaved]
Presentation on b trees [autosaved]
 
B trees
B treesB trees
B trees
 
BTrees - Great alternative to Red Black, AVL and other BSTs
BTrees - Great alternative to Red Black, AVL and other BSTsBTrees - Great alternative to Red Black, AVL and other BSTs
BTrees - Great alternative to Red Black, AVL and other BSTs
 
B+tree Data structures presentation
B+tree Data structures presentationB+tree Data structures presentation
B+tree Data structures presentation
 
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
 
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
 
2-3 Tree, Everything you need to know
2-3 Tree,  Everything you need to know2-3 Tree,  Everything you need to know
2-3 Tree, Everything you need to know
 
Modern Database Systems - Lecture 02
Modern Database Systems - Lecture 02Modern Database Systems - Lecture 02
Modern Database Systems - Lecture 02
 
LEC 7-DS ALGO(expression and huffman).pdf
LEC 7-DS  ALGO(expression and huffman).pdfLEC 7-DS  ALGO(expression and huffman).pdf
LEC 7-DS ALGO(expression and huffman).pdf
 
Binary tree
Binary treeBinary tree
Binary tree
 
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
 
08 B Trees
08 B Trees08 B Trees
08 B Trees
 
A41001011
A41001011A41001011
A41001011
 
[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing
 
B trees
B treesB trees
B trees
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 

Recently uploaded

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 

Recently uploaded (20)

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 

B+ tree

  • 1. B+-Trees Preethi B Department of Computer Science Coimbatore -43
  • 2. B+ TREE • A B+ tree is an n-array tree with a variable but often large number of children per node. • A B+ tree consists of a root, internal nodes and leaves. • The root may be either a leaf or a node with two or more children. • The primary value of a B+ tree is in storing data for efficient retrieval in a block-oriented storage context — in particular, file systems.
  • 3. Example Tree Index • Index entries:<search key value, page id> they direct search for data entries in leaves. • Example where each node can hold 2 entries; 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root
  • 4. ISAM (Indexed Sequential Access Method) 48* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 20 33 51 63 40 97* Root Overflow Pages Leaf Pages Primary 23* 41* 42* Index Pages
  • 5. Example B+ Tree • Search begins at root, and key comparisons direct it to a leaf. • Search for 5*, 15*, all data entries >= 24* ... Based on the search for 15*, we know it is not in the tree! Root 17 24 30 2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 13
  • 6. B+ Tree - Properties • Balanced • Every node except root must be at least ½ full. • Order: the minimum number of keys/pointers in a non-leaf node • Fanout of a node: the number of pointers out of the node
  • 7. B+ Trees in Practice • Typical order: 100. Typical fill-factor: 67%. – average fanout = 133 • Typical capacities: – Height 3: 1333 = 2,352,637 entries – Height 4: 1334 = 312,900,700 entries • Can often hold top levels in buffer pool: – Level 1 = 1 page = 8 Kbytes – Level 2 = 133 pages = 1 Mbyte – Level 3 = 17,689 pages = 133 MBytes
  • 8. B+ Trees: Summary • Searching: – logd(n) – Where d is the order, and n is the number of entries • Insertion: – Find the leaf to insert into – If full, split the node, and adjust index accordingly – Similar cost as searching • Deletion – Find the leaf node – Delete – May not remain half-full; must adjust the index accordingly
  • 9.
  • 10. Insert 23* Root 17 24 30 2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 13 Root 17 24 30 2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 13 23* No splitting required.
  • 11. Example B+ Tree - Inserting 8* Notice that root was split, leading to increase in height. In this example, we can avoid split by re-distributing entries; however, this is usually not done in practice. Root 17 24 30 2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 13 2* 3* Root 17 24 30 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 135 7*5* 8*
  • 12. Data vs. Index Page Split (from previous example of inserting “8”) • Observe how minimum occupancy is guaranteed in both leaf and index pg splits. • Note difference between copy-up and push-up; be sure you understand the reasons for this. 2* 3* 5* 7* 5 Entry to be inserted in parent node. (Note that 5 is continues to appear in the leaf.) s copied up and 2* 3* 5* 7* 8* … Data Page Split 8* 5 24 3013 appears once in the index. Contrast17 Entry to be inserted in parent node. (Note that 17 is pushed up and only this with a leaf split.) 17 24 3013Index Page Split 5
  • 13.
  • 14. Root 17 24 30 2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 13 2* 3* Root 17 24 30 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 135 7*5* 8* Delete 19* 2* 3* Root 17 24 30 14* 16* 20* 22* 24* 27* 29* 33* 34* 38* 39* 135 7*5* 8*
  • 15. Delete 20* ... 2* 3* Root 17 24 30 14* 16* 20* 22* 24* 27* 29* 33* 34* 38* 39* 135 7*5* 8* 2* 3* Root 17 27 30 14* 16* 22* 24* 27* 29* 33* 34* 38* 39* 135 7*5* 8*
  • 16. Delete 19* and 20* ... • Deleting 19* is easy. • Deleting 20* is done with re-distribution. Notice how middle key is copied up. • Further deleting 24* results in more drastic changes
  • 17. Delete 24* ... 2* 3* Root 17 27 30 14* 16* 22* 24* 27* 29* 33* 34* 38* 39* 135 7*5* 8* 2* 3* Root 17 27 30 14* 16* 22* 27* 29* 33* 34* 38* 39* 135 7*5* 8* No redistribution from neighbors possible
  • 18. Deleting 24* • Must merge. • Observe `toss’ of index entry (on right), and `pull down’ of index entry (below). 30 22* 27* 29* 33* 34* 38* 39* 2* 3* 7* 14* 16* 22* 27* 29* 33* 34* 38* 39*5* 8* Root 30135 17