A balanced binary tree over a string. Leaves hold short chunks; each internal node stores weight = characters in its left subtree. Index descends by weight (O(log n)); concat just makes a parent (O(1)); split partitions one path (O(log n)).
| Operation | Time | vs Flat string |
|---|---|---|
| Index char i | O(log n) | O(1) |
| Concat A+B | O(1) | O(a+b) |
| Split at i | O(log n) | O(n) |
| Insert / Delete | O(log n) | O(n) |
| Substring (m) | O(log n + m) | O(m) |
| Space | O(n) | O(n) |