SlideShare a Scribd company logo
1 of 63
Data StructuresB-tree Jibrael Jos : Sep 2009
Introduction Multiway Trees B Tree Application Structure Algo : Insert / Delete Avoid Taking Printout : Use RTF Outline in case needed 2 Agenda
Data Structures AVL Trees Red Black B-tree Hashing / Indexing Techniques Graphs  Please Do Not Take Printout : Use RTF Outline in case needed 3
Path Has to be enjoyed Walking Walking in Rain !! Certification Effort ~   Satisfaction Please Do Not Take Printout : Use RTF Outline in case needed 4
Research Shoulders of Giants Research on an area to reach a level of expertise Mindmap and Research Path Please Do Not Take Printout : Use RTF Outline in case needed 5
B Tree Please Do Not Take Printout : Use RTF Outline in case needed 6
Methodology One Book to Another One Link to Another Avoid Taking Printout : Use RTF Outline in case needed 7
Binary Search Tree What happens if data is loaded in a binary search tree in this order 23, 32, 45, 11, 43 , 41 1,2,3,4,5,6,7,8 What is AVL tree Please Do Not Take Printout : Use RTF Outline in case needed 8
Multiway Trees Please Do Not Take Printout : Use RTF Outline in case needed 9 >= K2 >= K1 <K2 < K1
m-way trees Reduce the depth of the tree to  O(logmn)with m-way trees mchildren,  m-1 keys per node m = 10  :  106 keys in 6 levels vs 20 for a binary tree but ........
m-way trees But you have to search through the m keys in each node! Reduces your gain from having fewer levels!
m-way trees
Anand B B-trees All leaves are on the same level All nodes except for the root and the leaveshave at least m/2 children at most m children Each node is at least half full of keys
BTREE
Disk Please Do Not Take Printout : Use RTF Outline in case needed 15 1 track = 5000 Chars 1 Cylinder = 20 tracks 1 disk unit = 200 cylinders
Time Taken Seek Time Latency Time Transmission Time Overcoming Latency Time ?? 72.5 + o.o5n millisec to read n chars
3 level Please Do Not Take Printout : Use RTF Outline in case needed 17
Multiway Tree M – ary tree 3 levels :  Cylinder , Track , Record : Index Seq (RDBMS) Tables with less change Please Do Not Take Printout : Use RTF Outline in case needed 18
BTree If level is 3,  m =199 then what is N How many split per insertion ? Please Do Not Take Printout : Use RTF Outline in case needed 19
Multiway Trees : Application NDPL , Delhi: Electricity Billing 3 lakh consumers  Table indexed as BTREE UCO Bank, Jaipur One DD takes 10 minutes to print Saviour : BTREE Please Do Not Take Printout : Use RTF Outline in case needed 20
B-trees - Insertion Insertion B-tree property : block is at least half-full of keys Insertion into block with m keys block overflows split block promote one key split parent if necessary if root is split, tree becomes one level deeper
Insert Node 63
After Insert 63
Insert Node 99
After Insert 99
Split Node 0 4 node
Structure of Btree node firstPtr numEntries      Entries[1.. M-1] End  Entry         key rightPtr End Entry Avoid Taking Printout : Use RTF Outline in case needed 27
Split Node : Final 0 4 3 median entry fromNdx 3 node 2 toNdx 2 rightPtr
Split Node : Final 4 4 3 median entry fromNdx 3 node 1 toNdx 2 rightPtr
Traversal
Delete Delete Walk Through Reflow Borrow Left Borrow Right Combine Delete Mid Avoid Taking Printout : Use RTF Outline in case needed 31 Agenda
Delete : For 78 Please Do Not Take Printout : Use RTF Outline in case needed 32 Btree Delete         Delete()                  Delete()                         Delete Mid()                          Reflow()                  Reflow()          If shorter delete root 1 2 2 2 2 2
Btree Delete If (root null)      print (“Attempt to delete from null tree”) Else      shorter = delete (root, target)      if Shorter            delete root  Return root Please Do Not Take Printout : Use RTF Outline in case needed 33 B Target = 78 1 2 2 2 2 2
Delete(root , deleteKey) If (root null)           data does not exist Else entryNdx= searchNode(root, deleteKey)             if found entry to be deleted                       if leaf node                           underflow=deleteEntry()                      else                            underflow=deleteMid (left)                             if underflow                                     underflow=reflow() Please Do Not Take Printout : Use RTF Outline in case needed 34 B D Target = 78 1 2 2 2 2 2
Delete Else Part Else            if deleteKey less than first entry subtree=firstPtr            else subtree=rightPtr            underflow= delete (subtree,deleteKey)            if underflow                 underflow= reflow() Return underflow Please Do Not Take Printout : Use RTF Outline in case needed 35 B D Target = 78 1 2 2 2 2 2
Delete(root , deleteKey) If (root null)           data does not exist Else entryNdx= searchNode(root, deleteKey)             if found entry to be deleted                       if leaf node                           underflow=deleteEntry()                      else                             underflow=deleteMid (root,entryIndx,left)                             if underflow                                     underflow=reflow(root,entryIndx) Please Do Not Take Printout : Use RTF Outline in case needed 36 B D D Target = 78 DM 1 2 2 2 2 2
Delete(root , deleteKey) Please Do Not Take Printout : Use RTF Outline in case needed 37 B If (root null)           data does not exist Else entryNdx= searchNode(root, deleteKey)             if found entry to be deleted                       if leaf node                           underflow=deleteEntry()                      else                           underflow=deleteMid (root,entryIndx,left)                             if underflow                                     underflow=reflow(root,entryIndx) D D 74 replaces 78 1 2 2 2 1 2
Delete(root , deleteKey) If (root null)           data does not exist Else entryNdx= searchNode(root, deleteKey)             if found entry to be deleted                       if leaf node                           underflow=deleteEntry()                      else                           underflow=deleteMid (root,entryIndx,left)                             if underflow                                     underflow=reflow(root,entryIndx) Please Do Not Take Printout : Use RTF Outline in case needed 38 B D D After Reflow 1 1 2 2 4
Delete Else Part Else            if deleteKey less than first entry subtree=firstPtr            else subtree=rightPtr            underflow= delete (subtree,deleteKey)            if underflow                 underflow= reflow(root,entryIndx) Return underflow Please Do Not Take Printout : Use RTF Outline in case needed 39 B D Before Reflow 1 1 2 2 4
Delete Else Part Else            if deleteKey less than first entry subtree=firstPtr            else subtree=rightPtr            underflow= delete (subtree,deleteKey)            if underflow                 underflow= reflow(root,entryIndx) Return underflow Please Do Not Take Printout : Use RTF Outline in case needed 40 B D After Reflow 0 4 2 4
BTREE Delete If (root null)      print (“Attempt to delete from null tree”) Else      shorter = delete (root, target)      if Shorter            delete root  Return root Please Do Not Take Printout : Use RTF Outline in case needed 41 B 0 4 2 4
BTREE Delete If (root null)      print (“Attempt to delete from null tree”) Else      shorter = delete (root, target)      if Shorter            delete root  Return root Please Do Not Take Printout : Use RTF Outline in case needed 42 B 4 2 4
Templates Please Do Not Take Printout : Use RTF Outline in case needed 43 3 4 2 1
Delete Please Do Not Take Printout : Use RTF Outline in case needed 44 1 2 2 2 2 2
Delete : For 78 Please Do Not Take Printout : Use RTF Outline in case needed 45 Btree Delete         Delete()                  Delete()                         Delete Mid()                          Reflow()                  Reflow()          If shorter delete root 1 2 2 2 2 2
Delete : Reflow 1: Try to borrow right.  2: If 1 failed try to borrow from left 3:  Cannot Borrow (1,2 failed)  Combine Please Do Not Take Printout : Use RTF Outline in case needed 46
Delete Reflow Underflow=false If RT->no  > min Entries BorrowRight (root,entryNdx,LT,RT) Else         If LT->no  > min Entries BorrowLeft (root,entryNdx,LT,RT) Else          combine (root,entryNdx,LT,RT)          if root->no < min entries                underflow=True Return underflow Please Do Not Take Printout : Use RTF Outline in case needed 47
Borrow Left Please Do Not Take Printout : Use RTF Outline in case needed 48 2 1 3 Node >= 74  < 78 Node >= 78  < 85
Combine Please Do Not Take Printout : Use RTF Outline in case needed 49 3 1 2 2 2
Combine Please Do Not Take Printout : Use RTF Outline in case needed 50 3 1 3 2 2
Combine Please Do Not Take Printout : Use RTF Outline in case needed 51 3 4 2 2
Combine Please Do Not Take Printout : Use RTF Outline in case needed 52 2 4 2 2
Delete Mid If leaf       exchange data and delete leaf entry Else        traverse right to locate predecessor deleteMid(right)              if underflow                       reflow Please Do Not Take Printout : Use RTF Outline in case needed 53
Delete Mid Please Do Not Take Printout : Use RTF Outline in case needed 54 1 2 2 2 2 2 Case 1: To Delete 78 we replace with 74
Delete Mid Please Do Not Take Printout : Use RTF Outline in case needed 55 1 2 2 2 2 2 Case 2: To Delete 78 we replace with 76 Hence recursive call of Delete Mid to locate predecessor 2
order Please Do Not Take Printout : Use RTF Outline in case needed 56
Get the Order Right  Keys are 4 Subtrees Max is 5 = Order is 5 Minimum = 3 (which is subtrees) Min Keys is 2 Please Do Not Take Printout : Use RTF Outline in case needed 57 4 2 4
2-3 Tree Order 3 ….. So how many keys in a node This rule is valid for non root leaf Root can have 0, 2, 3 subtrees Please Do Not Take Printout : Use RTF Outline in case needed 58
2 -3 Tree Please Do Not Take Printout : Use RTF Outline in case needed 59 1 2 2 2 2 2
2-3-4 Tree Order 4 ….. So how many keys in a node This rule is valid for non root leaf Root can have 0, 2, 3 subtrees Please Do Not Take Printout : Use RTF Outline in case needed 60
Structure of B + tree Non leaf node firstPtr numEntries      Entries[1.. M-1] End  Entry         key rightPtr End Entry Avoid Taking Printout : Use RTF Outline in case needed 61 ,[object Object]
firstPtr
numEntries

More Related Content

What's hot

Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search TreeZafar Ayub
 
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 TREESiddhi Shrivas
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureDharita Chokshi
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structuresNiraj Agarwal
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data StructureOm Prakash
 
Stacks & Queues
Stacks & QueuesStacks & Queues
Stacks & Queuestech4us
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeManishPrajapati78
 
Binary search trees
Binary search treesBinary search trees
Binary search treesDwight Sabio
 
Using either foldLeft or foldRight to concatenate the elements of list[T] usi...
Using either foldLeft or foldRight to concatenate the elements of list[T] usi...Using either foldLeft or foldRight to concatenate the elements of list[T] usi...
Using either foldLeft or foldRight to concatenate the elements of list[T] usi...Philip Schwarz
 
Stacks and queues
Stacks and queuesStacks and queues
Stacks and queuesAbbott
 
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queues
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queuesFallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queues
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queuesSnehilKeshari
 
Paper talk (presented by Prof. Ludaescher), WORKS workshop, 2010
Paper talk (presented by Prof. Ludaescher), WORKS workshop, 2010Paper talk (presented by Prof. Ludaescher), WORKS workshop, 2010
Paper talk (presented by Prof. Ludaescher), WORKS workshop, 2010Paolo Missier
 
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Philip Schwarz
 

What's hot (20)

Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
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 Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Fp growth
Fp growthFp growth
Fp growth
 
Chapter 11 ds
Chapter 11 dsChapter 11 ds
Chapter 11 ds
 
Chapter 6 ds
Chapter 6 dsChapter 6 ds
Chapter 6 ds
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
Stacks & Queues
Stacks & QueuesStacks & Queues
Stacks & Queues
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Using either foldLeft or foldRight to concatenate the elements of list[T] usi...
Using either foldLeft or foldRight to concatenate the elements of list[T] usi...Using either foldLeft or foldRight to concatenate the elements of list[T] usi...
Using either foldLeft or foldRight to concatenate the elements of list[T] usi...
 
Stacks and queues
Stacks and queuesStacks and queues
Stacks and queues
 
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queues
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queuesFallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queues
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queues
 
Paper talk (presented by Prof. Ludaescher), WORKS workshop, 2010
Paper talk (presented by Prof. Ludaescher), WORKS workshop, 2010Paper talk (presented by Prof. Ludaescher), WORKS workshop, 2010
Paper talk (presented by Prof. Ludaescher), WORKS workshop, 2010
 
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Sequence and Traverse - Part 2
Sequence and Traverse - Part 2
 

Viewers also liked (20)

B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 
B tree
B treeB tree
B tree
 
B Trees
B TreesB Trees
B Trees
 
B trees dbms
B trees dbmsB trees dbms
B trees dbms
 
B-Tree
B-TreeB-Tree
B-Tree
 
Best for b trees
Best for b treesBest for b trees
Best for b trees
 
b+ tree
b+ treeb+ tree
b+ tree
 
B tree short
B tree shortB tree short
B tree short
 
B tree
B treeB tree
B tree
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
B+ trees
B+ treesB+ trees
B+ trees
 
Nikhat b+ trees ppt
Nikhat b+ trees pptNikhat b+ trees ppt
Nikhat b+ trees ppt
 
Algorithm Introduction #18 B-Tree
Algorithm Introduction #18 B-TreeAlgorithm Introduction #18 B-Tree
Algorithm Introduction #18 B-Tree
 
B tree &
B tree &B tree &
B tree &
 
B trees and_b__trees
B trees and_b__treesB trees and_b__trees
B trees and_b__trees
 
B+ Tree
B+ TreeB+ Tree
B+ Tree
 
Fibonacci Heap
Fibonacci HeapFibonacci Heap
Fibonacci Heap
 
Trie Data Structure
Trie Data StructureTrie Data Structure
Trie Data Structure
 
Splay Tree
Splay TreeSplay Tree
Splay Tree
 
Concept of hashing
Concept of hashingConcept of hashing
Concept of hashing
 

Similar to BTree, Data Structures

CS-102 BST_27_3_14v2.pdf
CS-102 BST_27_3_14v2.pdfCS-102 BST_27_3_14v2.pdf
CS-102 BST_27_3_14v2.pdfssuser034ce1
 
Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil duttAnil Dutt
 
Data Structures, Graphs
Data Structures, GraphsData Structures, Graphs
Data Structures, GraphsJibrael Jos
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11ecomputernotes
 
Lecture4b dynamic data_structure
Lecture4b dynamic data_structureLecture4b dynamic data_structure
Lecture4b dynamic data_structurembadhi barnabas
 
(a)PreOrder, PostOrder and Inorder are three ways you can iterate .pdf
(a)PreOrder, PostOrder and Inorder are three ways you can iterate .pdf(a)PreOrder, PostOrder and Inorder are three ways you can iterate .pdf
(a)PreOrder, PostOrder and Inorder are three ways you can iterate .pdfANANDSHOE
 
Lecture_10 - Revised.pptx
Lecture_10 - Revised.pptxLecture_10 - Revised.pptx
Lecture_10 - Revised.pptxRedHeart11
 
chapter5.PPT
chapter5.PPTchapter5.PPT
chapter5.PPTSaralaT3
 
ds 10-Binary Tree.ppt
ds 10-Binary Tree.pptds 10-Binary Tree.ppt
ds 10-Binary Tree.pptkhitishlpu
 
(a) There are three ways to traverse a binary tree pre-order, in-or.docx
(a) There are three ways to traverse a binary tree pre-order, in-or.docx(a) There are three ways to traverse a binary tree pre-order, in-or.docx
(a) There are three ways to traverse a binary tree pre-order, in-or.docxajoy21
 
Purely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaPurely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaVladimir Kostyukov
 
Add these three functions to the class binaryTreeType (provided).W.pdf
Add these three functions to the class binaryTreeType (provided).W.pdfAdd these three functions to the class binaryTreeType (provided).W.pdf
Add these three functions to the class binaryTreeType (provided).W.pdfindiaartz
 

Similar to BTree, Data Structures (19)

CS-102 BST_27_3_14v2.pdf
CS-102 BST_27_3_14v2.pdfCS-102 BST_27_3_14v2.pdf
CS-102 BST_27_3_14v2.pdf
 
Binary tree
Binary treeBinary tree
Binary tree
 
Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil dutt
 
Data Structures, Graphs
Data Structures, GraphsData Structures, Graphs
Data Structures, Graphs
 
Trees gt(1)
Trees gt(1)Trees gt(1)
Trees gt(1)
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11
 
4.2 bst 03
4.2 bst 034.2 bst 03
4.2 bst 03
 
Lecture4b dynamic data_structure
Lecture4b dynamic data_structureLecture4b dynamic data_structure
Lecture4b dynamic data_structure
 
(a)PreOrder, PostOrder and Inorder are three ways you can iterate .pdf
(a)PreOrder, PostOrder and Inorder are three ways you can iterate .pdf(a)PreOrder, PostOrder and Inorder are three ways you can iterate .pdf
(a)PreOrder, PostOrder and Inorder are three ways you can iterate .pdf
 
Data Structures
Data StructuresData Structures
Data Structures
 
Lecture_10 - Revised.pptx
Lecture_10 - Revised.pptxLecture_10 - Revised.pptx
Lecture_10 - Revised.pptx
 
Lec16
Lec16Lec16
Lec16
 
chapter5.PPT
chapter5.PPTchapter5.PPT
chapter5.PPT
 
ds 10-Binary Tree.ppt
ds 10-Binary Tree.pptds 10-Binary Tree.ppt
ds 10-Binary Tree.ppt
 
B tree
B  treeB  tree
B tree
 
(a) There are three ways to traverse a binary tree pre-order, in-or.docx
(a) There are three ways to traverse a binary tree pre-order, in-or.docx(a) There are three ways to traverse a binary tree pre-order, in-or.docx
(a) There are three ways to traverse a binary tree pre-order, in-or.docx
 
Purely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaPurely Functional Data Structures in Scala
Purely Functional Data Structures in Scala
 
Add these three functions to the class binaryTreeType (provided).W.pdf
Add these three functions to the class binaryTreeType (provided).W.pdfAdd these three functions to the class binaryTreeType (provided).W.pdf
Add these three functions to the class binaryTreeType (provided).W.pdf
 

More from Jibrael Jos

Followership, A Leadership Workshop
Followership, A Leadership WorkshopFollowership, A Leadership Workshop
Followership, A Leadership WorkshopJibrael Jos
 
Steven Covey 7 Habits of Highly Effective People
Steven Covey 7 Habits of Highly Effective PeopleSteven Covey 7 Habits of Highly Effective People
Steven Covey 7 Habits of Highly Effective PeopleJibrael Jos
 
Big Bang to DNA , Relatively Speaking
Big Bang to DNA , Relatively SpeakingBig Bang to DNA , Relatively Speaking
Big Bang to DNA , Relatively SpeakingJibrael Jos
 
Data Structures : Sort Explained
Data Structures : Sort ExplainedData Structures : Sort Explained
Data Structures : Sort ExplainedJibrael Jos
 
Data Structures : Sorting
Data Structures : SortingData Structures : Sorting
Data Structures : SortingJibrael Jos
 
Data Structures : AVL Trees
Data Structures : AVL TreesData Structures : AVL Trees
Data Structures : AVL TreesJibrael Jos
 

More from Jibrael Jos (6)

Followership, A Leadership Workshop
Followership, A Leadership WorkshopFollowership, A Leadership Workshop
Followership, A Leadership Workshop
 
Steven Covey 7 Habits of Highly Effective People
Steven Covey 7 Habits of Highly Effective PeopleSteven Covey 7 Habits of Highly Effective People
Steven Covey 7 Habits of Highly Effective People
 
Big Bang to DNA , Relatively Speaking
Big Bang to DNA , Relatively SpeakingBig Bang to DNA , Relatively Speaking
Big Bang to DNA , Relatively Speaking
 
Data Structures : Sort Explained
Data Structures : Sort ExplainedData Structures : Sort Explained
Data Structures : Sort Explained
 
Data Structures : Sorting
Data Structures : SortingData Structures : Sorting
Data Structures : Sorting
 
Data Structures : AVL Trees
Data Structures : AVL TreesData Structures : AVL Trees
Data Structures : AVL Trees
 

Recently uploaded

Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsRommel Regala
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Recently uploaded (20)

Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World Politics
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 

BTree, Data Structures

  • 2. Introduction Multiway Trees B Tree Application Structure Algo : Insert / Delete Avoid Taking Printout : Use RTF Outline in case needed 2 Agenda
  • 3. Data Structures AVL Trees Red Black B-tree Hashing / Indexing Techniques Graphs Please Do Not Take Printout : Use RTF Outline in case needed 3
  • 4. Path Has to be enjoyed Walking Walking in Rain !! Certification Effort ~ Satisfaction Please Do Not Take Printout : Use RTF Outline in case needed 4
  • 5. Research Shoulders of Giants Research on an area to reach a level of expertise Mindmap and Research Path Please Do Not Take Printout : Use RTF Outline in case needed 5
  • 6. B Tree Please Do Not Take Printout : Use RTF Outline in case needed 6
  • 7. Methodology One Book to Another One Link to Another Avoid Taking Printout : Use RTF Outline in case needed 7
  • 8. Binary Search Tree What happens if data is loaded in a binary search tree in this order 23, 32, 45, 11, 43 , 41 1,2,3,4,5,6,7,8 What is AVL tree Please Do Not Take Printout : Use RTF Outline in case needed 8
  • 9. Multiway Trees Please Do Not Take Printout : Use RTF Outline in case needed 9 >= K2 >= K1 <K2 < K1
  • 10. m-way trees Reduce the depth of the tree to O(logmn)with m-way trees mchildren, m-1 keys per node m = 10 : 106 keys in 6 levels vs 20 for a binary tree but ........
  • 11. m-way trees But you have to search through the m keys in each node! Reduces your gain from having fewer levels!
  • 13. Anand B B-trees All leaves are on the same level All nodes except for the root and the leaveshave at least m/2 children at most m children Each node is at least half full of keys
  • 14. BTREE
  • 15. Disk Please Do Not Take Printout : Use RTF Outline in case needed 15 1 track = 5000 Chars 1 Cylinder = 20 tracks 1 disk unit = 200 cylinders
  • 16. Time Taken Seek Time Latency Time Transmission Time Overcoming Latency Time ?? 72.5 + o.o5n millisec to read n chars
  • 17. 3 level Please Do Not Take Printout : Use RTF Outline in case needed 17
  • 18. Multiway Tree M – ary tree 3 levels : Cylinder , Track , Record : Index Seq (RDBMS) Tables with less change Please Do Not Take Printout : Use RTF Outline in case needed 18
  • 19. BTree If level is 3, m =199 then what is N How many split per insertion ? Please Do Not Take Printout : Use RTF Outline in case needed 19
  • 20. Multiway Trees : Application NDPL , Delhi: Electricity Billing 3 lakh consumers Table indexed as BTREE UCO Bank, Jaipur One DD takes 10 minutes to print Saviour : BTREE Please Do Not Take Printout : Use RTF Outline in case needed 20
  • 21. B-trees - Insertion Insertion B-tree property : block is at least half-full of keys Insertion into block with m keys block overflows split block promote one key split parent if necessary if root is split, tree becomes one level deeper
  • 26. Split Node 0 4 node
  • 27. Structure of Btree node firstPtr numEntries Entries[1.. M-1] End Entry key rightPtr End Entry Avoid Taking Printout : Use RTF Outline in case needed 27
  • 28. Split Node : Final 0 4 3 median entry fromNdx 3 node 2 toNdx 2 rightPtr
  • 29. Split Node : Final 4 4 3 median entry fromNdx 3 node 1 toNdx 2 rightPtr
  • 31. Delete Delete Walk Through Reflow Borrow Left Borrow Right Combine Delete Mid Avoid Taking Printout : Use RTF Outline in case needed 31 Agenda
  • 32. Delete : For 78 Please Do Not Take Printout : Use RTF Outline in case needed 32 Btree Delete Delete() Delete() Delete Mid() Reflow() Reflow() If shorter delete root 1 2 2 2 2 2
  • 33. Btree Delete If (root null) print (“Attempt to delete from null tree”) Else shorter = delete (root, target) if Shorter delete root Return root Please Do Not Take Printout : Use RTF Outline in case needed 33 B Target = 78 1 2 2 2 2 2
  • 34. Delete(root , deleteKey) If (root null) data does not exist Else entryNdx= searchNode(root, deleteKey) if found entry to be deleted if leaf node underflow=deleteEntry() else underflow=deleteMid (left) if underflow underflow=reflow() Please Do Not Take Printout : Use RTF Outline in case needed 34 B D Target = 78 1 2 2 2 2 2
  • 35. Delete Else Part Else if deleteKey less than first entry subtree=firstPtr else subtree=rightPtr underflow= delete (subtree,deleteKey) if underflow underflow= reflow() Return underflow Please Do Not Take Printout : Use RTF Outline in case needed 35 B D Target = 78 1 2 2 2 2 2
  • 36. Delete(root , deleteKey) If (root null) data does not exist Else entryNdx= searchNode(root, deleteKey) if found entry to be deleted if leaf node underflow=deleteEntry() else underflow=deleteMid (root,entryIndx,left) if underflow underflow=reflow(root,entryIndx) Please Do Not Take Printout : Use RTF Outline in case needed 36 B D D Target = 78 DM 1 2 2 2 2 2
  • 37. Delete(root , deleteKey) Please Do Not Take Printout : Use RTF Outline in case needed 37 B If (root null) data does not exist Else entryNdx= searchNode(root, deleteKey) if found entry to be deleted if leaf node underflow=deleteEntry() else underflow=deleteMid (root,entryIndx,left) if underflow underflow=reflow(root,entryIndx) D D 74 replaces 78 1 2 2 2 1 2
  • 38. Delete(root , deleteKey) If (root null) data does not exist Else entryNdx= searchNode(root, deleteKey) if found entry to be deleted if leaf node underflow=deleteEntry() else underflow=deleteMid (root,entryIndx,left) if underflow underflow=reflow(root,entryIndx) Please Do Not Take Printout : Use RTF Outline in case needed 38 B D D After Reflow 1 1 2 2 4
  • 39. Delete Else Part Else if deleteKey less than first entry subtree=firstPtr else subtree=rightPtr underflow= delete (subtree,deleteKey) if underflow underflow= reflow(root,entryIndx) Return underflow Please Do Not Take Printout : Use RTF Outline in case needed 39 B D Before Reflow 1 1 2 2 4
  • 40. Delete Else Part Else if deleteKey less than first entry subtree=firstPtr else subtree=rightPtr underflow= delete (subtree,deleteKey) if underflow underflow= reflow(root,entryIndx) Return underflow Please Do Not Take Printout : Use RTF Outline in case needed 40 B D After Reflow 0 4 2 4
  • 41. BTREE Delete If (root null) print (“Attempt to delete from null tree”) Else shorter = delete (root, target) if Shorter delete root Return root Please Do Not Take Printout : Use RTF Outline in case needed 41 B 0 4 2 4
  • 42. BTREE Delete If (root null) print (“Attempt to delete from null tree”) Else shorter = delete (root, target) if Shorter delete root Return root Please Do Not Take Printout : Use RTF Outline in case needed 42 B 4 2 4
  • 43. Templates Please Do Not Take Printout : Use RTF Outline in case needed 43 3 4 2 1
  • 44. Delete Please Do Not Take Printout : Use RTF Outline in case needed 44 1 2 2 2 2 2
  • 45. Delete : For 78 Please Do Not Take Printout : Use RTF Outline in case needed 45 Btree Delete Delete() Delete() Delete Mid() Reflow() Reflow() If shorter delete root 1 2 2 2 2 2
  • 46. Delete : Reflow 1: Try to borrow right. 2: If 1 failed try to borrow from left 3: Cannot Borrow (1,2 failed) Combine Please Do Not Take Printout : Use RTF Outline in case needed 46
  • 47. Delete Reflow Underflow=false If RT->no > min Entries BorrowRight (root,entryNdx,LT,RT) Else If LT->no > min Entries BorrowLeft (root,entryNdx,LT,RT) Else combine (root,entryNdx,LT,RT) if root->no < min entries underflow=True Return underflow Please Do Not Take Printout : Use RTF Outline in case needed 47
  • 48. Borrow Left Please Do Not Take Printout : Use RTF Outline in case needed 48 2 1 3 Node >= 74 < 78 Node >= 78 < 85
  • 49. Combine Please Do Not Take Printout : Use RTF Outline in case needed 49 3 1 2 2 2
  • 50. Combine Please Do Not Take Printout : Use RTF Outline in case needed 50 3 1 3 2 2
  • 51. Combine Please Do Not Take Printout : Use RTF Outline in case needed 51 3 4 2 2
  • 52. Combine Please Do Not Take Printout : Use RTF Outline in case needed 52 2 4 2 2
  • 53. Delete Mid If leaf exchange data and delete leaf entry Else traverse right to locate predecessor deleteMid(right) if underflow reflow Please Do Not Take Printout : Use RTF Outline in case needed 53
  • 54. Delete Mid Please Do Not Take Printout : Use RTF Outline in case needed 54 1 2 2 2 2 2 Case 1: To Delete 78 we replace with 74
  • 55. Delete Mid Please Do Not Take Printout : Use RTF Outline in case needed 55 1 2 2 2 2 2 Case 2: To Delete 78 we replace with 76 Hence recursive call of Delete Mid to locate predecessor 2
  • 56. order Please Do Not Take Printout : Use RTF Outline in case needed 56
  • 57. Get the Order Right Keys are 4 Subtrees Max is 5 = Order is 5 Minimum = 3 (which is subtrees) Min Keys is 2 Please Do Not Take Printout : Use RTF Outline in case needed 57 4 2 4
  • 58. 2-3 Tree Order 3 ….. So how many keys in a node This rule is valid for non root leaf Root can have 0, 2, 3 subtrees Please Do Not Take Printout : Use RTF Outline in case needed 58
  • 59. 2 -3 Tree Please Do Not Take Printout : Use RTF Outline in case needed 59 1 2 2 2 2 2
  • 60. 2-3-4 Tree Order 4 ….. So how many keys in a node This rule is valid for non root leaf Root can have 0, 2, 3 subtrees Please Do Not Take Printout : Use RTF Outline in case needed 60
  • 61.
  • 64. Entries[1.. M-1]
  • 65. Next Leaf Node
  • 66.
  • 67. B * Tree Space Usage BTREE nodes can be 50% Empty (1/2) So rule modified to two third (2/3) Also when node overflows instead of being split immed distributed with siblings And even when split happens all siblings are equally distributed (pg 462) Please Do Not Take Printout : Use RTF Outline in case needed 63
  • 68. B+-trees B+ trees All the keys in the nodes are dummies Only the keys in the leaves point to “real” data Linking the leaves Ability to scan the collection in orderwithout passing through the higher nodes
  • 69.