Home▸Algorithms & AI▸Index Structures Compared: B-Tree, Binary Search Tree and Hash Table Lookup Costs

Index Structures Compared: B-Tree, Binary Search Tree and Hash Table Lookup Costs

Index Structures Compared: B-Tree, Binary Search Tree and Hash Table Lookup Costs.

Algorithms & AI3DModerate60 FPS📱 Mobile-adapted🟠 Blender⇄ 2D version
Index Structures Compared: B-Tree, Binary Search Tree and Hash Table Lookup Costs ↗ Open standalone

A database index trades memory and write effort for fast lookups, and the right structure depends on what a lookup costs. This simulator stores random keys in a real B-tree, a binary search tree grown in random order, a sorted array and two open-addressing hash tables, runs thousands of lookups on them, and counts key comparisons and disk-page reads. The measured averages are shown next to the textbook closed forms: probes of 1/2(1+1/(1-a)) and 1/2(1+1/(1-a)^2) for linear probing, 1/(1-a) for double hashing, 2(1+1/N)H_N - 3 for a random binary search tree and the logarithmic height bounds of a B-tree.

⚙ Under the hood

Index Structures Compared: B-Tree, Binary Search Tree and Hash Table Lookup Costs.

indexdata structuresB-treehash tablebinary search treedatabasealgorithmsThree.jsopen addressing

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)