🗓️ 05112024 2350
📎
b_tree
ABSTRACT
Data structure used to manage large amounts of data efficiently
Maintain sorted data and allow for logarithmic time complexity for search / insert / delete operations
Structure / Properties
- Each node in a B-Tree can contain
- number of keys (
m
) - up to
m-1
children
- number of keys (
- For balance
- All nodes maintain a minimum number of keys
- All leaf nodes are at the same level
NOTE
The height of a B-Tree is logarithmic relative to the number of keys, ensuring efficient access
Operations
Search
- Start at root
- Recursively traverses down tree
- At each node
- Check if key present OR
- Determine which child node to explore based on comparisons with the keys in the node
Insert
- Find appropriate leaf node
- If node full (max number of keys)
- split into two nodes
- Promote a key to parent node
- Continue up the key if necessary
Delete
- Locate key
- if internal node
- Replace with in-order predecessor / successor
Ensure that nodes maintain minimum key requirement