KEMBAR78
B+tree Data structures presentation | PPTX
PRESENTING YOU
TREES
• It’s an another n-ary Tree
• It actually is an optimization of B tree
• Contains root, internal nodes and leaf nodes like other Trees
• Internal nodes contains router value of data in leaves
• All data is stored at leaf level
• Leaf nodes are linked to each other
What actually is B+ Tree?
19
5 17 19 45
45
• Unlike B tree, B+ tree stores all the data on leaf level.
• They Maximize the branching factors (fanout)
• Higher branching factors allows less height
• Less height requires less disk I/O
• Which means better performance
WHY B+ Tree?
19
5 17 19 45
O(log 𝑏 𝑛)
• Every node has one more children than it has keys.
• All leaves are at the same distance from the root.
• If B+ tree has m order then
• Root: has between 2 and m children (or root could be a leaf).
• Internal Node: store up to m - 1 and have between ⎡m/2⎤ and m children.
• Leaf Nodes: where data is stored and all at the same depth, contain between
⎡L/2⎤ and L data items.
• Order Property: subtree between two keys x and y contain leaves with values v
such that x ≤ v < y
Properties of B+ Tree
y
x v y v
• Insert at bottom level
• If leaf page (node) overflows, split page and copy middle element to
next index page
• If index page (node) overflows, split page and move middle element
to next index page
Insertion Rules
• Max Order (m): 3
• Insert 5
• Insert 45
• Insert 13
Let’s do some Insertion
5
13
Split
45
13
45 13 45
• Max Order (m): 3
• Insert 5
• Insert 45
• Insert 13
• Insert 23
Let’s do some Insertion
5 45
13
4513
23
Split
45
23
4523
• Max Order (m): 3
• Insert 5
• Insert 45
• Insert 13
• Insert 23
• Insert 32
Let’s do some Insertion
5 45
13
13
23
4523
32
Split
45
32
4532
• Max Order (m): 3
• Insert 5
• Insert 45
• Insert 13
• Insert 23
• Insert 32
Let’s do some Insertion
5 45
13
13
23
23
Split
45
32
4532
23
• Delete key and data from leaf page.
• If leaf page underflows, merge with sibling and delete key in between
them.
• If index page underflows, merge with sibling and move down key in
between them
Deletion Rules
• Delete 23
Let’s apply deletion on previous tree
5 45
13
13 23 45
32
4532
2332
45
45
32
• Delete 23
• Delete 13
Let’s apply deletion on previous tree
5
13
13 45
45
32
32
32
45
45
32
Cases Insertion Deletion Searching Space
Best Ω(log 𝑏 𝑛) Ω(log 𝑏 𝑛) Ω(log 𝑏 𝑛) Ω(𝑛)
Average θ(log 𝑏 𝑛) θ(log 𝑏 𝑛) θ(log 𝑏 𝑛) θ(𝑛 + k)
Worst O(log 𝑏 𝑛) O(log 𝑏 𝑛) O(𝑏. log 𝑏 𝑛) O(𝑛 + k)
Complexities
Where b = order
n = number of keys in the tree
Comparison Analysis
Features B Tree B+ Tree
Storage
In a B tree, search keys and data
stored in internal or leaf nodes.
In a B+ tree, data stored only in leaf
nodes.
Function of leaf nodes
In B tree, the leaf node cannot
store using linked list.
In B+ tree, leaf node data are
ordered in a sequential linked list.
Search accessibility
Here in B tree the search is not that
easy as compared to a B+ tree.
Here in B+ tree the searching
becomes easy.
Redundant key
They do not store redundant search
key.
They store redundant search key.
Applications
B+ trees are used by
• NTFS, ReiserFS, NSS, XFS, JFS, ReFS, and BFS file systems for metadata
indexing
• BFS for storing directories.
• IBM DB2, Informix, Microsoft SQL Server, Oracle 8, Sybase ASE, and SQLite for
table indexes
Conclusion
B Tree
B+ Tree
It’s a Q/A time now

B+tree Data structures presentation

  • 1.
  • 2.
    • It’s ananother n-ary Tree • It actually is an optimization of B tree • Contains root, internal nodes and leaf nodes like other Trees • Internal nodes contains router value of data in leaves • All data is stored at leaf level • Leaf nodes are linked to each other What actually is B+ Tree? 19 5 17 19 45 45
  • 3.
    • Unlike Btree, B+ tree stores all the data on leaf level. • They Maximize the branching factors (fanout) • Higher branching factors allows less height • Less height requires less disk I/O • Which means better performance WHY B+ Tree? 19 5 17 19 45 O(log 𝑏 𝑛)
  • 4.
    • Every nodehas one more children than it has keys. • All leaves are at the same distance from the root. • If B+ tree has m order then • Root: has between 2 and m children (or root could be a leaf). • Internal Node: store up to m - 1 and have between ⎡m/2⎤ and m children. • Leaf Nodes: where data is stored and all at the same depth, contain between ⎡L/2⎤ and L data items. • Order Property: subtree between two keys x and y contain leaves with values v such that x ≤ v < y Properties of B+ Tree y x v y v
  • 5.
    • Insert atbottom level • If leaf page (node) overflows, split page and copy middle element to next index page • If index page (node) overflows, split page and move middle element to next index page Insertion Rules
  • 6.
    • Max Order(m): 3 • Insert 5 • Insert 45 • Insert 13 Let’s do some Insertion 5 13 Split 45 13 45 13 45
  • 7.
    • Max Order(m): 3 • Insert 5 • Insert 45 • Insert 13 • Insert 23 Let’s do some Insertion 5 45 13 4513 23 Split 45 23 4523
  • 8.
    • Max Order(m): 3 • Insert 5 • Insert 45 • Insert 13 • Insert 23 • Insert 32 Let’s do some Insertion 5 45 13 13 23 4523 32 Split 45 32 4532
  • 9.
    • Max Order(m): 3 • Insert 5 • Insert 45 • Insert 13 • Insert 23 • Insert 32 Let’s do some Insertion 5 45 13 13 23 23 Split 45 32 4532 23
  • 10.
    • Delete keyand data from leaf page. • If leaf page underflows, merge with sibling and delete key in between them. • If index page underflows, merge with sibling and move down key in between them Deletion Rules
  • 11.
    • Delete 23 Let’sapply deletion on previous tree 5 45 13 13 23 45 32 4532 2332 45 45 32
  • 12.
    • Delete 23 •Delete 13 Let’s apply deletion on previous tree 5 13 13 45 45 32 32 32 45 45 32
  • 13.
    Cases Insertion DeletionSearching Space Best Ω(log 𝑏 𝑛) Ω(log 𝑏 𝑛) Ω(log 𝑏 𝑛) Ω(𝑛) Average θ(log 𝑏 𝑛) θ(log 𝑏 𝑛) θ(log 𝑏 𝑛) θ(𝑛 + k) Worst O(log 𝑏 𝑛) O(log 𝑏 𝑛) O(𝑏. log 𝑏 𝑛) O(𝑛 + k) Complexities Where b = order n = number of keys in the tree
  • 14.
    Comparison Analysis Features BTree B+ Tree Storage In a B tree, search keys and data stored in internal or leaf nodes. In a B+ tree, data stored only in leaf nodes. Function of leaf nodes In B tree, the leaf node cannot store using linked list. In B+ tree, leaf node data are ordered in a sequential linked list. Search accessibility Here in B tree the search is not that easy as compared to a B+ tree. Here in B+ tree the searching becomes easy. Redundant key They do not store redundant search key. They store redundant search key.
  • 15.
    Applications B+ trees areused by • NTFS, ReiserFS, NSS, XFS, JFS, ReFS, and BFS file systems for metadata indexing • BFS for storing directories. • IBM DB2, Informix, Microsoft SQL Server, Oracle 8, Sybase ASE, and SQLite for table indexes
  • 16.
  • 17.
    It’s a Q/Atime now