B-Tree

A B-tree is a self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time.

🌐 Termes dans d'autres langues:
Contenu en attente de traduction. Affichage de la version anglaise.

Properties: 1. Self-balancing: All leaf nodes are at the exact same depth. 2. Sorted: Keys within a node are kept in order. 3. Multi-way: Nodes have between m/2 and m children. 4. Efficient: Designed for systems that read/write blocks of data. Variants: B+ Tree (leaves linked), B* Tree (better space utilization).

        graph LR
  Center["B-Tree"]:::main
  Pre_load_balancer["load-balancer"]:::pre --> Center
  click Pre_load_balancer "/terms/load-balancer"
  Rel_high_availability["high-availability"]:::related -.-> Center
  click Rel_high_availability "/terms/high-availability"
  Rel_recursion["recursion"]:::related -.-> Center
  click Rel_recursion "/terms/recursion"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 Explique-moi comme si j'avais 5 ans

Imagine a giant library. A [binary](/fr/terms/binary) [tree](/fr/terms/tree) is like asking for directions and being told 'Left' or 'Right' at every single shelf. A B-tree is like being handed a map that says exactly which hallway, which floor, and which shelf to look on. You find your book with many fewer steps because each node gives you many more choices at once.

🤓 Expert Deep Dive

The efficiency of a B-tree comes from its ability to minimize disk I/O. Since reading a block of data from a disk takes significantly longer than CPU processing, B-tree nodes are sized to match the disk's block size (typically 4KB to 16KB). Each node contains multiple sorted keys and pointers to children. When a node becomes full, it 'splits' into two, and the median key is promoted to the parent. This recursive process ensures the tree remains perfectly balanced, guaranteeing O(log n) performance for all major operations. B+ Trees, a common variant, store all actual data records in the leaf nodes, connected by a linked list, which significantly improves range query performance.

🔗 Termes associés

Prérequis:

📚 Sources