[Verse 1]
B-tree standing tall, balanced and wide
Keys in order, children by their side
Minimum degree determines the flow
Half full nodes, that's how we grow
Split when full, merge when sparse
Every path same length, near and far
Root to leaf, same distance down
B-tree keeps our data sound
[Chorus]
Insert and split, merge and borrow
Keep it balanced for tomorrow
Half full rule, never break
Split the full, for balance sake
Insert and split, merge and borrow
Keys in order, straight and narrow
[Verse 2]
Insertion starts at the leaf node level
Find the spot where new key settles
If the leaf is not yet full
Drop it in, simple pull
But when the node hits maximum capacity
Split in half with median key
Middle rises to parent above
Left and right nodes show their love
[Chorus]
Insert and split, merge and borrow
Keep it balanced for tomorrow
Half full rule, never break
Split the full, for balance sake
Insert and split, merge and borrow
Keys in order, straight and narrow
[Verse 3]
Deletion gets a bit more complex
Find the key, what happens next
If it's in a leaf that's not too small
Just remove it, that's all
But if the leaf goes under minimum
Borrow from sibling, redistribute them
Or merge with neighbor, combine as one
Parent key comes down, the deed is done
[Bridge]
When internal nodes lose their keys
Replace with predecessor with ease
Or successor from the right subtree
Maintain order, keep it free
Cascading splits climb up the tree
Root might split, new root we see
Height increases, balanced still
B-tree bends to our data will
[Chorus]
Insert and split, merge and borrow
Keep it balanced for tomorrow
Half full rule, never break
Split the full, for balance sake
Insert and split, merge and borrow
Keys in order, straight and narrow
[Outro]
Logarithmic time for every operation
Search and insert, perfect relation
B-tree standing, strong and true
Balanced data structure through and through