Master the fundamental concepts of build a simple key-value store through this focused micro-challenge.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksLSM trees buffer writes in a memtable, usually a skip list or red-black tree, before flushing immutable SSTables to disk. RocksDB and LevelDB use skip lists for concurrent inserts with reader-writer friendly locking.
Expected O(log n) search with simpler concurrency than balanced trees. Each level skips forward with coin-flip height.
cLoading…
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 implement a skip list memtable supporting insert and lookup. This exercise requires maintaining sorted order and expected logarithmic search steps.
Document one invariant you will assert in tests and how you would detect its violation from observable symptoms.
LSM-tree stores such as LevelDB and RocksDB buffer writes in a skip list memtable: a sorted linked list with extra "express" levels on top, giving O(log n) search with simple, lock-friendly inserts. Build one with MAX_LEVEL = 4.
put gives it, so results are reproducible. Clamp it to 1-4.Commands until the end of input:
put K V Lget Klevelsdumpput: put 15=150 level=2 for a new key, put 15=999 updated for an existing one.get: get 15 -> 150 (comparisons=3), or get 99 -> -1 (comparisons=2) when the key is absent.levels: one line per level from 3 down to 0, such as L1: 10 25 or L3: (empty).dump: sorted: 5=50 10=100 15=150 with every pair in key order.