SlideShare a Scribd company logo
1 of 7
B tree
B tree follow binary search tree property
Order of tree is the number of pointers stored in tree.
If order = 3 then number of key elements in each node =2 (i.e, order-1)
Btree is used for indexing
The node values are primary keys
Insertion into B tree
8
Insert the following elements into B-tree of order 3
8 5 7 1 3 9
Since order of Btree =3
Number of keys that can be stored in each node = 2
Number of pointers in each node =3 Keys
pointers
Insert 5
5
Since there is place to insert one more key in the root node, we insert 5 in the
root node itself
Since 5 is < 8 we insert 5 to the left of 8 in the root node
8
Insert 7
7
We cannot insert 7 in root node as each node can store only 2 keys
So of the three elements 5 7 and 8 , the middle element is 7
So we split as shown below.
In this way all the elements that are less than 7 is to the left of 7
And all the elements that are greater than 7 is to the right
5 8
Insert 1
7
Since 1 is < 7 , we move to the node that is left of root node
In left node, since 1< 5 we insert 1 as shown below
1 85
Insert 3
3
Since 3 is < 7 , we move to the node that is left of root node
In left node, since 1<3 and 3< 5 we have to insert 3 in the left node
As a node cannot store more than 2 keys we cannot insert 3
So n 1,3,5 the middle element is 3 and so we move 3 to the root node
As follows
1 8
7
5
Insert 9
3
1 8
7
5 9

More Related Content

More from Lakshmi Sarvani Videla

More from Lakshmi Sarvani Videla (20)

Recursive functions in C
Recursive functions in CRecursive functions in C
Recursive functions in C
 
Function Pointer in C
Function Pointer in CFunction Pointer in C
Function Pointer in C
 
Functions
FunctionsFunctions
Functions
 
Java sessionnotes
Java sessionnotesJava sessionnotes
Java sessionnotes
 
Singlelinked list
Singlelinked listSinglelinked list
Singlelinked list
 
Graphs
GraphsGraphs
Graphs
 
Functions in python3
Functions in python3Functions in python3
Functions in python3
 
Dictionary
DictionaryDictionary
Dictionary
 
Sets
SetsSets
Sets
 
Lists
ListsLists
Lists
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
C programs
C programsC programs
C programs
 
Data Mining: Data Preprocessing
Data Mining: Data PreprocessingData Mining: Data Preprocessing
Data Mining: Data Preprocessing
 
Dbms
DbmsDbms
Dbms
 
Computer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesComputer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notes
 
Complete Operating System notes
Complete Operating System notesComplete Operating System notes
Complete Operating System notes
 
Computer ScienceTechnical quiz
Computer ScienceTechnical quizComputer ScienceTechnical quiz
Computer ScienceTechnical quiz
 
Networks notes
Networks notesNetworks notes
Networks notes
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
 

Recently uploaded

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Recently uploaded (20)

Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Buy Epson EcoTank L3210 Colour Printer Online.pdf
Buy Epson EcoTank L3210 Colour Printer Online.pdfBuy Epson EcoTank L3210 Colour Printer Online.pdf
Buy Epson EcoTank L3210 Colour Printer Online.pdf
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 

B trees

  • 1. B tree B tree follow binary search tree property Order of tree is the number of pointers stored in tree. If order = 3 then number of key elements in each node =2 (i.e, order-1) Btree is used for indexing The node values are primary keys
  • 2. Insertion into B tree 8 Insert the following elements into B-tree of order 3 8 5 7 1 3 9 Since order of Btree =3 Number of keys that can be stored in each node = 2 Number of pointers in each node =3 Keys pointers
  • 3. Insert 5 5 Since there is place to insert one more key in the root node, we insert 5 in the root node itself Since 5 is < 8 we insert 5 to the left of 8 in the root node 8
  • 4. Insert 7 7 We cannot insert 7 in root node as each node can store only 2 keys So of the three elements 5 7 and 8 , the middle element is 7 So we split as shown below. In this way all the elements that are less than 7 is to the left of 7 And all the elements that are greater than 7 is to the right 5 8
  • 5. Insert 1 7 Since 1 is < 7 , we move to the node that is left of root node In left node, since 1< 5 we insert 1 as shown below 1 85
  • 6. Insert 3 3 Since 3 is < 7 , we move to the node that is left of root node In left node, since 1<3 and 3< 5 we have to insert 3 in the left node As a node cannot store more than 2 keys we cannot insert 3 So n 1,3,5 the middle element is 3 and so we move 3 to the root node As follows 1 8 7 5