SlideShare a Scribd company logo
File Processing & Organization
Course No: 5901227-3
Lecture 7
B-Trees (Continued)
Inserting a key into a B-tree in a single
pass down the tree
• The B-TREE-INSERT procedure uses B-TREE-SPLIT-CHILD to
guarantee that the recursion never descends to a full node.
B-TREE-INSERT(T, k)
1 r ← root[T]
2 if n[r] = 2t - 1
3 then s ← ALLOCATE-NODE()
4 root[T] ← s
5 leaf[s] ← FALSE
6 n[s] ← 0
7 c1[s] ← r
8 B-TREE-SPLIT-CHILD(s, 1, r)
9 B-TREE-INSERT-NONFULL(s, k)
10 else B-TREE-INSERT-NONFULL(r, k)
• Lines 3-9 handle the case in which the root node r
is full: the root is split and a new node s (having
two children) becomes the root. Splitting the root
is the only way to increase the height of a B-tree.
Figure 1 illustrates this case.
• The procedure finishes by calling BTREE-INSERT-
NONFULL to perform the insertion of key k in the
tree rooted at the nonfull root node.
Figure 1
• Splitting the root with t = 4. Root node r is split in two, and a
new root node s is created. The new root contains the median
key of r and has the two halves of r as children.
• The B-tree grows in height by one when the root is split.
B-TREE-INSERT-NONFULL
• B-TREE-INSERT-NONFULL(x, k)
1 i ← n[x]
2 if leaf[x]
3 then while i ≥ 1 and k < keyi[x]
4 do keyi+1[x] ← keyi[x]
5 i ← i - 1
6 keyi+1[x] ← k
7 n[x] ← n[x] + 1
8 DISK-WRITE(x)
9 else while i ≥ 1 and k < keyi[x]
10 do i ← i - 1
11 i ← i + 1
12 DISK-READ(ci[x])
13 if n[ci[x]] = 2t - 1
14 then B-TREE-SPLIT-CHILD(x, i, ci[x])
15 if k> keyi[x]
16 then i ← i + 1
17 B-TREE-INSERT-NONFULL(ci[x], k)
• Lines 3-8 handle the case in which x is a leaf node
by inserting key k into x. If x is not a leaf node,
then we must insert k into the appropriate leaf
node in the subtree rooted at internal node x.
• In this case, lines 9-11 determine the child of x to
which the recursion descends.
• Lines 13-16 guarantee that the procedure never
recurses to a full node.
• Line 17 then recurses to insert k into the
appropriate subtree.
Deleting a key from a B-tree
• Just as we had to ensure that a node didn't
get too big due to insertion, we must ensure
that a node doesn't get too small during
deletion
Deleting a key from a B-tree
• Delete key B from a B-Tree with t=3.
D G
A B C E F H I
Deleting a key from a B-tree
We want to delete key F from a B-Tree
with t =3.
D G
A B C E F H I
Deleting a key from a B-tree
We want to delete key F from a B-Tree
with t =3.
G
A B C D E F H I
Deleting a key from a B-tree
We want to delete key F from a B-Tree
with t =3.
C G
A B D E F H I
Deleting a key from a B-tree
We want to delete key S from a B-Tree
with t=3.
Q T
OP R S U X
Deleting a key from a B-tree
We want to delete key S from a B-Tree
with t=3.
Q T
OP R S T U X
Deleting a key from a B-tree
Q U
O P R S T W V
Deleting a key from a B-tree
We want to delete key U from a B-Tree
with t=3.
Q T
O P R S W V
Deleting a key from a B-tree
• We want to delete I from a B-Tree with t =3.
I H
G M J K L O P
Deleting a key from a B-tree
• We want to delete I from a B-Tree with t =3.
J H
G M K L O P
Deleting a key from a B-tree
• We want to delete U from a B-Tree with t =3.
R U X
P Q ST V W Y Z
Deleting a key from a B-tree
• We want to delete U from a B-Tree with t =3.
R X
P Q S T V W Y Z

More Related Content

What's hot

Smu bca sem 3 fall 2015 assignments
Smu bca sem 3 fall 2015 assignmentsSmu bca sem 3 fall 2015 assignments
Smu bca sem 3 fall 2015 assignments
solved_assignments
 
Addsub poly
Addsub polyAddsub poly
Addsub poly
zoffben
 
R merge-tutorial
R merge-tutorialR merge-tutorial
R merge-tutorial
Wayne Lee
 
Factoring polynomials with common monomial factor
Factoring polynomials with common monomial factorFactoring polynomials with common monomial factor
Factoring polynomials with common monomial factor
Gauben Malicsi
 
Smu bca sem 3 spring 2016 assignments
Smu bca sem 3 spring 2016 assignmentsSmu bca sem 3 spring 2016 assignments
Smu bca sem 3 spring 2016 assignments
solved_assignments
 
5.5 roots of real numbers
5.5 roots of real numbers5.5 roots of real numbers
5.5 roots of real numbers
Jessica Garcia
 
Completing the square class notes
Completing the square   class notesCompleting the square   class notes
Completing the square class notes
Steven Jackson
 
Pascal Triangle
Pascal TrianglePascal Triangle
Pascal Triangle
Liza Heh
 
4 ESO Academics - Unit 01 - Exercises 1.3.
4 ESO Academics - Unit 01 - Exercises 1.3.4 ESO Academics - Unit 01 - Exercises 1.3.
4 ESO Academics - Unit 01 - Exercises 1.3.
Gogely The Great
 
Chapter4.3
Chapter4.3Chapter4.3
Chapter4.3
nglaze10
 
Edu 290 ppt 2
Edu 290 ppt 2Edu 290 ppt 2
Edu 290 ppt 2
marti13a
 
Edu 290 ppt 1
Edu 290 ppt 1Edu 290 ppt 1
Edu 290 ppt 1
marti13a
 
Chirp_Mass
Chirp_MassChirp_Mass
Chirp_Mass
Marc King
 
Alegebra Powers Substitution
Alegebra Powers SubstitutionAlegebra Powers Substitution
Alegebra Powers Substitution
Passy World
 
Ch 1 review stations (Classwork)
Ch 1 review stations (Classwork)Ch 1 review stations (Classwork)
Ch 1 review stations (Classwork)
leblance
 
Chapter 4.3b - GCF with variables
Chapter 4.3b - GCF with variablesChapter 4.3b - GCF with variables
Chapter 4.3b - GCF with variables
Kathy Favazza
 
The Max Cut Problem
The Max Cut ProblemThe Max Cut Problem
The Max Cut Problem
dnatapov
 
Expand brackets 1
Expand brackets 1Expand brackets 1
Expand brackets 1
Patryk Mamica
 
Can you count on your computer?
Can you count on your computer?Can you count on your computer?
Can you count on your computer?
Hamed Zakerzadeh
 

What's hot (19)

Smu bca sem 3 fall 2015 assignments
Smu bca sem 3 fall 2015 assignmentsSmu bca sem 3 fall 2015 assignments
Smu bca sem 3 fall 2015 assignments
 
Addsub poly
Addsub polyAddsub poly
Addsub poly
 
R merge-tutorial
R merge-tutorialR merge-tutorial
R merge-tutorial
 
Factoring polynomials with common monomial factor
Factoring polynomials with common monomial factorFactoring polynomials with common monomial factor
Factoring polynomials with common monomial factor
 
Smu bca sem 3 spring 2016 assignments
Smu bca sem 3 spring 2016 assignmentsSmu bca sem 3 spring 2016 assignments
Smu bca sem 3 spring 2016 assignments
 
5.5 roots of real numbers
5.5 roots of real numbers5.5 roots of real numbers
5.5 roots of real numbers
 
Completing the square class notes
Completing the square   class notesCompleting the square   class notes
Completing the square class notes
 
Pascal Triangle
Pascal TrianglePascal Triangle
Pascal Triangle
 
4 ESO Academics - Unit 01 - Exercises 1.3.
4 ESO Academics - Unit 01 - Exercises 1.3.4 ESO Academics - Unit 01 - Exercises 1.3.
4 ESO Academics - Unit 01 - Exercises 1.3.
 
Chapter4.3
Chapter4.3Chapter4.3
Chapter4.3
 
Edu 290 ppt 2
Edu 290 ppt 2Edu 290 ppt 2
Edu 290 ppt 2
 
Edu 290 ppt 1
Edu 290 ppt 1Edu 290 ppt 1
Edu 290 ppt 1
 
Chirp_Mass
Chirp_MassChirp_Mass
Chirp_Mass
 
Alegebra Powers Substitution
Alegebra Powers SubstitutionAlegebra Powers Substitution
Alegebra Powers Substitution
 
Ch 1 review stations (Classwork)
Ch 1 review stations (Classwork)Ch 1 review stations (Classwork)
Ch 1 review stations (Classwork)
 
Chapter 4.3b - GCF with variables
Chapter 4.3b - GCF with variablesChapter 4.3b - GCF with variables
Chapter 4.3b - GCF with variables
 
The Max Cut Problem
The Max Cut ProblemThe Max Cut Problem
The Max Cut Problem
 
Expand brackets 1
Expand brackets 1Expand brackets 1
Expand brackets 1
 
Can you count on your computer?
Can you count on your computer?Can you count on your computer?
Can you count on your computer?
 

Similar to Fileprocessing lec-7

b-tree.ppt
b-tree.pptb-tree.ppt
b-tree.ppt
SyedAhsan232061
 
B tree
B  treeB  tree
Lecture_10 - Revised.pptx
Lecture_10 - Revised.pptxLecture_10 - Revised.pptx
Lecture_10 - Revised.pptx
RedHeart11
 
PEA 305.pdf
PEA 305.pdfPEA 305.pdf
PEA 305.pdf
SofiaSingla3
 
Chapter 09-Trees
Chapter 09-TreesChapter 09-Trees
Chapter 09-Trees
MuhammadBakri13
 
BTree.pptx
BTree.pptxBTree.pptx
BTree.pptx
ssuser4fbfbf
 
Lecture 11 data structures and algorithms
Lecture 11 data structures and algorithmsLecture 11 data structures and algorithms
Lecture 11 data structures and algorithms
Aakash deep Singhal
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
Dwight Sabio
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
AdityaK92
 
C12 bst
C12 bstC12 bst
C12 bst
C12 bstC12 bst
lecture10 date structure types of graph and terminology
lecture10 date structure types of graph and terminologylecture10 date structure types of graph and terminology
lecture10 date structure types of graph and terminology
KamranAli649587
 
Form 5 Additional Maths Note
Form 5 Additional Maths NoteForm 5 Additional Maths Note
Form 5 Additional Maths Note
Chek Wei Tan
 
Lec16
Lec16Lec16
10.m way search tree
10.m way search tree10.m way search tree
10.m way search tree
Chandan Singh
 
DSA (Data Structure and Algorithm) Questions
DSA (Data Structure and Algorithm) QuestionsDSA (Data Structure and Algorithm) Questions
DSA (Data Structure and Algorithm) Questions
RESHAN FARAZ
 
(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
ajoy21
 
5220191CS146 Data Structures and AlgorithmsC.docx
5220191CS146 Data Structures and AlgorithmsC.docx5220191CS146 Data Structures and AlgorithmsC.docx
5220191CS146 Data Structures and AlgorithmsC.docx
fredharris32
 
B trees
B treesB trees
B tree by-jash acharya
B tree by-jash acharyaB tree by-jash acharya
B tree by-jash acharya
Jash Acharya
 

Similar to Fileprocessing lec-7 (20)

b-tree.ppt
b-tree.pptb-tree.ppt
b-tree.ppt
 
B tree
B  treeB  tree
B tree
 
Lecture_10 - Revised.pptx
Lecture_10 - Revised.pptxLecture_10 - Revised.pptx
Lecture_10 - Revised.pptx
 
PEA 305.pdf
PEA 305.pdfPEA 305.pdf
PEA 305.pdf
 
Chapter 09-Trees
Chapter 09-TreesChapter 09-Trees
Chapter 09-Trees
 
BTree.pptx
BTree.pptxBTree.pptx
BTree.pptx
 
Lecture 11 data structures and algorithms
Lecture 11 data structures and algorithmsLecture 11 data structures and algorithms
Lecture 11 data structures and algorithms
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
C12 bst
C12 bstC12 bst
C12 bst
 
C12 bst
C12 bstC12 bst
C12 bst
 
lecture10 date structure types of graph and terminology
lecture10 date structure types of graph and terminologylecture10 date structure types of graph and terminology
lecture10 date structure types of graph and terminology
 
Form 5 Additional Maths Note
Form 5 Additional Maths NoteForm 5 Additional Maths Note
Form 5 Additional Maths Note
 
Lec16
Lec16Lec16
Lec16
 
10.m way search tree
10.m way search tree10.m way search tree
10.m way search tree
 
DSA (Data Structure and Algorithm) Questions
DSA (Data Structure and Algorithm) QuestionsDSA (Data Structure and Algorithm) Questions
DSA (Data Structure and Algorithm) Questions
 
(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
 
5220191CS146 Data Structures and AlgorithmsC.docx
5220191CS146 Data Structures and AlgorithmsC.docx5220191CS146 Data Structures and AlgorithmsC.docx
5220191CS146 Data Structures and AlgorithmsC.docx
 
B trees
B treesB trees
B trees
 
B tree by-jash acharya
B tree by-jash acharyaB tree by-jash acharya
B tree by-jash acharya
 

More from sawsan slii

Ch1 traditional it and cloud
Ch1 traditional it and cloudCh1 traditional it and cloud
Ch1 traditional it and cloud
sawsan slii
 
Aws principle services: IAM,VPC, EC2, Cloudwatch
Aws principle services: IAM,VPC, EC2, CloudwatchAws principle services: IAM,VPC, EC2, Cloudwatch
Aws principle services: IAM,VPC, EC2, Cloudwatch
sawsan slii
 
Introduction to exploring hci
Introduction to exploring hciIntroduction to exploring hci
Introduction to exploring hci
sawsan slii
 
Design principles
Design principlesDesign principles
Design principles
sawsan slii
 
Introduction hci
Introduction hciIntroduction hci
Introduction hci
sawsan slii
 
Ch1 traditional it and cloud
Ch1 traditional it and cloudCh1 traditional it and cloud
Ch1 traditional it and cloud
sawsan slii
 
Cache mapping exercises
Cache mapping exercisesCache mapping exercises
Cache mapping exercises
sawsan slii
 
evaluation techniques in HCI
evaluation techniques in HCIevaluation techniques in HCI
evaluation techniques in HCI
sawsan slii
 
Evaluation techniques in HCI
Evaluation techniques in HCIEvaluation techniques in HCI
Evaluation techniques in HCI
sawsan slii
 
Ajax and xml
Ajax and xmlAjax and xml
Ajax and xml
sawsan slii
 
UCD and low-fidelity prototyping
UCD and low-fidelity prototypingUCD and low-fidelity prototyping
UCD and low-fidelity prototyping
sawsan slii
 
Web forms and server side scripting
Web forms and server side scriptingWeb forms and server side scripting
Web forms and server side scripting
sawsan slii
 
Web server administration
Web server administrationWeb server administration
Web server administration
sawsan slii
 

More from sawsan slii (13)

Ch1 traditional it and cloud
Ch1 traditional it and cloudCh1 traditional it and cloud
Ch1 traditional it and cloud
 
Aws principle services: IAM,VPC, EC2, Cloudwatch
Aws principle services: IAM,VPC, EC2, CloudwatchAws principle services: IAM,VPC, EC2, Cloudwatch
Aws principle services: IAM,VPC, EC2, Cloudwatch
 
Introduction to exploring hci
Introduction to exploring hciIntroduction to exploring hci
Introduction to exploring hci
 
Design principles
Design principlesDesign principles
Design principles
 
Introduction hci
Introduction hciIntroduction hci
Introduction hci
 
Ch1 traditional it and cloud
Ch1 traditional it and cloudCh1 traditional it and cloud
Ch1 traditional it and cloud
 
Cache mapping exercises
Cache mapping exercisesCache mapping exercises
Cache mapping exercises
 
evaluation techniques in HCI
evaluation techniques in HCIevaluation techniques in HCI
evaluation techniques in HCI
 
Evaluation techniques in HCI
Evaluation techniques in HCIEvaluation techniques in HCI
Evaluation techniques in HCI
 
Ajax and xml
Ajax and xmlAjax and xml
Ajax and xml
 
UCD and low-fidelity prototyping
UCD and low-fidelity prototypingUCD and low-fidelity prototyping
UCD and low-fidelity prototyping
 
Web forms and server side scripting
Web forms and server side scriptingWeb forms and server side scripting
Web forms and server side scripting
 
Web server administration
Web server administrationWeb server administration
Web server administration
 

Recently uploaded

Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 

Recently uploaded (20)

Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 

Fileprocessing lec-7

  • 1. File Processing & Organization Course No: 5901227-3 Lecture 7 B-Trees (Continued)
  • 2. Inserting a key into a B-tree in a single pass down the tree • The B-TREE-INSERT procedure uses B-TREE-SPLIT-CHILD to guarantee that the recursion never descends to a full node. B-TREE-INSERT(T, k) 1 r ← root[T] 2 if n[r] = 2t - 1 3 then s ← ALLOCATE-NODE() 4 root[T] ← s 5 leaf[s] ← FALSE 6 n[s] ← 0 7 c1[s] ← r 8 B-TREE-SPLIT-CHILD(s, 1, r) 9 B-TREE-INSERT-NONFULL(s, k) 10 else B-TREE-INSERT-NONFULL(r, k)
  • 3. • Lines 3-9 handle the case in which the root node r is full: the root is split and a new node s (having two children) becomes the root. Splitting the root is the only way to increase the height of a B-tree. Figure 1 illustrates this case. • The procedure finishes by calling BTREE-INSERT- NONFULL to perform the insertion of key k in the tree rooted at the nonfull root node.
  • 4. Figure 1 • Splitting the root with t = 4. Root node r is split in two, and a new root node s is created. The new root contains the median key of r and has the two halves of r as children. • The B-tree grows in height by one when the root is split.
  • 5. B-TREE-INSERT-NONFULL • B-TREE-INSERT-NONFULL(x, k) 1 i ← n[x] 2 if leaf[x] 3 then while i ≥ 1 and k < keyi[x] 4 do keyi+1[x] ← keyi[x] 5 i ← i - 1 6 keyi+1[x] ← k 7 n[x] ← n[x] + 1 8 DISK-WRITE(x) 9 else while i ≥ 1 and k < keyi[x]
  • 6. 10 do i ← i - 1 11 i ← i + 1 12 DISK-READ(ci[x]) 13 if n[ci[x]] = 2t - 1 14 then B-TREE-SPLIT-CHILD(x, i, ci[x]) 15 if k> keyi[x] 16 then i ← i + 1 17 B-TREE-INSERT-NONFULL(ci[x], k)
  • 7. • Lines 3-8 handle the case in which x is a leaf node by inserting key k into x. If x is not a leaf node, then we must insert k into the appropriate leaf node in the subtree rooted at internal node x. • In this case, lines 9-11 determine the child of x to which the recursion descends. • Lines 13-16 guarantee that the procedure never recurses to a full node. • Line 17 then recurses to insert k into the appropriate subtree.
  • 8. Deleting a key from a B-tree • Just as we had to ensure that a node didn't get too big due to insertion, we must ensure that a node doesn't get too small during deletion
  • 9. Deleting a key from a B-tree • Delete key B from a B-Tree with t=3. D G A B C E F H I
  • 10. Deleting a key from a B-tree We want to delete key F from a B-Tree with t =3. D G A B C E F H I
  • 11. Deleting a key from a B-tree We want to delete key F from a B-Tree with t =3. G A B C D E F H I
  • 12. Deleting a key from a B-tree We want to delete key F from a B-Tree with t =3. C G A B D E F H I
  • 13. Deleting a key from a B-tree We want to delete key S from a B-Tree with t=3. Q T OP R S U X
  • 14. Deleting a key from a B-tree We want to delete key S from a B-Tree with t=3. Q T OP R S T U X
  • 15. Deleting a key from a B-tree Q U O P R S T W V
  • 16. Deleting a key from a B-tree We want to delete key U from a B-Tree with t=3. Q T O P R S W V
  • 17. Deleting a key from a B-tree • We want to delete I from a B-Tree with t =3. I H G M J K L O P
  • 18. Deleting a key from a B-tree • We want to delete I from a B-Tree with t =3. J H G M K L O P
  • 19. Deleting a key from a B-tree • We want to delete U from a B-Tree with t =3. R U X P Q ST V W Y Z
  • 20. Deleting a key from a B-tree • We want to delete U from a B-Tree with t =3. R X P Q S T V W Y Z