DATA STRUCTURES SIMULATION

With a million keys, a straight scan of an array averages five hundred thousand comparisons, a balanced binary search tree takes about twenty, and a hash table jumps to the right bucket in a single move. The catch is real: feed the tree already-sorted increasing data and every new value falls to the right, the tree stretches into a single chain n levels deep and search sinks back to O(n). The fuller a hash table gets, the more keys land in the same bucket, the longer the chain inside it, and the more that O(1) holds only on average. A heap keeps every parent below its children throughout, so the root is always the smallest value.

▸ Generating a deterministic value sequence (seeded PRNG)…
▸ Building the binary search tree (insert · search · balance)
▸ Loading the hash table (hash function · collisions · chaining)
▸ Loading the min-heap (sift-up · sift-down)
▸ Hashing discrete steps for replay
▸ Ready — Online. ✅
0%
⌂ Mind & Machine

Simulation room Data structures

Trees · Hash tables · Heaps
Online
tree · hash · heap · Big-O
Structure & cost
🌳 BST tree
Structure—
Nodes / keys—
Tree height—
Comparisons—
Load factor α—
Complexity—
Notes
A data structure is a way of organizing data in memory for efficient operations. For the same task of "finding a key", a BST tree (O(log n)), a hash table (O(1)) and an array (O(n)) cost very differently at scale.
—
Pick a ‘Scenario’ to change the structure (BST · degenerate · hash · collision · heap · cost compare) · 🔀 new data to rebuild · click a concept for details
Your browser has canvas disabled.
Items & cumulative comparisons over time itemscomparisons
About Data Structures

With a million keys, a straight scan of an array averages five hundred thousand comparisons, a balanced binary search tree takes about twenty, and a hash table jumps to the right bucket in a single move. The catch is real: feed the tree already-sorted increasing data and every new value falls to the right, the tree stretches into a single chain n levels deep and search sinks back to O(n). The fuller a hash table gets, the more keys land in the same bucket, the longer the chain inside it, and the more that O(1) holds only on average. A heap keeps every parent below its children throughout, so the root is always the smallest value.

Related topics in Mind & Machine