CS 411 Fall 2025 > Outline & Supplemental Notes for October 22, 2025
CS 411 Fall 2025
Outline & Supplemental Notes
for October 22, 2025
Outline
B-Trees [L 7.4]
- Idea
  - Balanced search trees: way of stored associative data that gives logarithmic time for all CRUD operations.
- B-Trees: balanced search trees that allow for very large nodes.
- B-Trees good when we wish to minimize number of nodes accessed. Good for external tables on block-access devices. Make node same size as block?
 
- Definition
  - Order of a B-Tree: \(m\ge 3\). This is maximum number of children a node can have.
- Nodes can contain multiple key-value pairs. A non-leaf has one more child than the number of keys it contains.
- Ordered much like a Binary Search Tree, generalized for nodes containing multiple keys.
- Root contains \(1\,\dots\,m-1\) keys.
- Each other node contains \(\lceil m/2 \rceil-1\,\dots\,m-1\) keys.
- All leaves at same level (so “flat on the bottom”).
 
- Algorithms
  - Retrieve algorithm
    - Start at root and work down, much like Binary Search Tree.
 
- Insert algorithm
    - Find the leaf to insert into (start at root, work down).
- If space in leaf node, insert there.
- If leaf would become overfull, then insert new item, split leaf, and insert center item in parent.
- Work up the tree in this way.
- If root is overfull, split and make new root.
 
- Delete algorithm
    - Will not cover details. Similar to insert, but a bit more complicated. Work down from root, then back up, fixing the tree.
 
 
- Retrieve algorithm
    
- Analysis
  - CRUD are logarithmic-time, like all balanced search trees.
- Height of tree is at most something like \(\log_{m/2}n\). Compare Red-Black Tree which has height at most something like \(2\,\log_2 n\). And number of nodes accessed is something like the height of the tree.
 
- B-Tree vs. B+ Tree
  - We have described a classical B-Tree.
- Variant: B+ Tree (described in text).
    - Each key in a non-leaf is duplicated in a leaf.
- Associated values are found only in leaves.
- So non-leaves function as index into leaves.
- Leaves may be organized into a linked list.
 
 
Supplemental Notes
B-Tree vs. B+ Tree
The B-Tree described in the text is more properly a B+ Tree. In a proper B-Tree, each key occurs in only one node, and the leaves are not organized into a linked list. However, B+ Trees are often called B-Trees, for some reason.