Master the fundamental concepts of b-trees through this focused micro-challenge.
B-tree nodes pack sorted keys and child pointers in a fixed fanout so each node fits one disk page (commonly 4KB/8KB). PostgreSQL B-Tree pages, SQLite table b-trees, and InnoDB indexes share this on-disk shape even when in-memory prototypes use smaller degrees for teaching.
Leaf flag, key count, parallel arrays of keys and values or child pointers, plus parent link if mutable.
cLoading…
t means keys per node between t-1 and 2t-1 (except root)Keep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will define a B-tree node struct and print its layout fields. This exercise requires showing how many keys fit given MAX_KEYS and page size constants.
Write a C program that defines and prints a B-tree node structure.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github