Loading links and building the hash table…

Free URL shortener · DSA Micro Project 02

Short links,
hashed in plain sight.

Paste a long URL to get a short one. Then see exactly how a hand-written hash table stores it, resolves collisions and finds it again.

Choose your own ending (optional)
velerion.github.io/

Letters, numbers, “-” and “_”, up to 24 characters.

Find or delete a link

Paste a short link or just its code. All three data structures search for it, and each one's comparison count is shown. You can delete only links created in this browser.

How it works

Every link is stored three ways: in a hash table with separate chaining, in a hash table with open addressing, and in a plain linked list for comparison.

The hash function

A short code is turned into a bucket number, one character at a time:

h = (h × 31 + character code) mod m

Start with h = 0. Taking the remainder at every step keeps the numbers small, and the final h is the bucket. The same code always gives the same bucket, so finding a link means checking just that one bucket.

Recent activity · circular queue, capacity 10

Undo stack · last in, first out