Master the fundamental concepts of b-trees through this focused micro-challenge.
On-disk B-trees map each node to a page with a header (page id, type, checksum) followed by serialized keys and offsets. SQLite and PostgreSQL read exactly one page per tree level during a cache miss.
Header, key count, key array, child page ids, free space pointer for inserts.
cLoading…
PAGE_SIZE minus headerKeep 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 serialize and deserialize a B-tree node into a byte buffer of fixed page size. This exercise requires round-tripping keys without loss and reporting bytes used.
Write a C program that serializes and deserializes B-tree nodes to fixed-size pages.
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