Skip to main content

B-tree of order 5 for letters C N G A H ...

Short answer

Construct by sequential insertion; overflow at 5 keys, split median up. Final tree: root [M], internal nodes [D G] and [Q T], leaf nodes [A C], [E F], [H K L], [N P], [R S], [W X Y Z].

Construct B-tree of order 5 for the set of data C N G A H E K Q M F W L T Z D P R X Y S showing each step.

Order 5 means at most 4 keys per node and at least 2 keys in a non-root node. Letters are compared alphabetically. When a node reaches 5 keys it is split at the median (3rd key), which moves up.

Step-by-step construction

StepInsertTree after stepAction
1C[C]fits in leaf
2N[C N]fits in leaf
3G[C G N]fits in leaf
4A[A C G N]fits in leaf
5H[G]{[A C], [H N]}leaf [A C G H N] overflows, split: G moves up; new root
6E[G]{[A C E], [H N]}fits in leaf
7K[G]{[A C E], [H K N]}fits in leaf
8Q[G]{[A C E], [H K N Q]}fits in leaf
9M[G M]{[A C E], [H K], [N Q]}leaf [H K M N Q] overflows, split: M moves up
10F[G M]{[A C E F], [H K], [N Q]}fits in leaf
11W[G M]{[A C E F], [H K], [N Q W]}fits in leaf
12L[G M]{[A C E F], [H K L], [N Q W]}fits in leaf
13T[G M]{[A C E F], [H K L], [N Q T W]}fits in leaf
14Z[G M T]{[A C E F], [H K L], [N Q], [W Z]}leaf [N Q T W Z] overflows, split: T moves up
15D[D G M T]{[A C], [E F], [H K L], [N Q], [W Z]}leaf [A C D E F] overflows, split: D moves up
16P[D G M T]{[A C], [E F], [H K L], [N P Q], [W Z]}fits in leaf
17R[D G M T]{[A C], [E F], [H K L], [N P Q R], [W Z]}fits in leaf
18X[D G M T]{[A C], [E F], [H K L], [N P Q R], [W X Z]}fits in leaf
19Y[D G M T]{[A C], [E F], [H K L], [N P Q R], [W X Y Z]}fits in leaf
20S[M]{[D G]{[A C], [E F], [H K L]}, [Q T]{[N P], [R S], [W X Y Z]}}leaf [N P Q R S] overflows, split: Q moves up; internal node [D G M Q T] overflows, split: M moves up; new root

Final B-tree of order 5

[M]
[D G]  [Q T]
[A C]  [E F]  [H K L]  [N P]  [R S]  [W X Y Z]

Tree height is 3 levels (root, one internal level, leaves).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Structure and Algorithm chapter 6 questions →