pisan-labs

Data Structure City — Data skill for Claude Code

Data community

Type Redis-like commands and watch a hash map, a B-tree, a skip list and an LRU cache change shape side by side, with per-operation cost meters and guided tours that ask you to predict each rehash, sp.

How to install Data Structure City

This entry records only its repository, not the path inside it, so there is no exact command to give. Open pisan-labs/data-structure-city and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Data Structure City does

Type Redis-like commands and watch a hash map, a B-tree, a skip list and an LRU cache change shape side by side, with per-operation cost meters and guided tours that ask you to predict each rehash, split or eviction. Built with Claude Code.

Alternatives in Data

README

Data Structure City

Four buildings and one console. Every command you type runs against a **hash map**, a **B-tree**, a **skip list** and an **LRU cache** at the same time, so you can watch each one change shape and compare what the same operation cost in each.

Live:

![FILL 8 builds a hash map, B-tree, skip list and LRU cache at once and reports each rehash and node split, GET k1 hits in three buildings but misses in the LRU cache, and DEL k2 merges two B-tree nodes, with per-building cost meters](demo.gif)

Built from the idea "Data Structure City" (2026-09-26, #2) in [`pisanuw/daily-project-ideas`](https://github.com/pisanuw/daily-project-ideas).

What you can do

  • Type Redis-like commands: SET key value [EX ticks], GET, DEL, EXPIRE, TTL, TICK, RANGE lo hi, FILL n [prefix], CAPACITY n, SEED n, KEYS, RESET, HELP. Up arrow recalls history; / focuses the console from anywhere.
  • Watch the internals:
    • Hash map: separate chaining, 4 buckets to start, doubles when the load factor would pass 0.75. Collided buckets are outlined; a rehash moves every entry, and the meter shows the spike.
    • B-tree: minimum degree 2 (a 2-3-4 tree), CLRS-style: full nodes split on the way down, and deletes borrow from or merge with a sibling on the way down. Splits, merges, borrows, growth and shrinkage are reported.
    • Skip list: p = 1/2 towers from a seeded PRNG, so the same commands and seed build the same city for every student. SEED n picks another.
    • LRU cache: hash index plus a recency list, 5 slots by default. Hits move to the front; a full cache evicts the tail. It forgets on purpose, so GET can miss in the cache while the other three buildings hit.
  • Read the cost meters: each building shows the last operation's cost, the running mean (the amortized cost) and the worst single operation, split into probes (buckets, nodes, slots visited)