Can someone provide an algorithm similar to TinyURL?
This was selected as Best Answer I think that the page I have referenced below will provide you with an excellent answer to your question: “As we have established, there are 62,193,780 possible values for TinyURL’s. TinyURL’s are generated by a Base 36 hash (36 indicating the number of characters a-z and 0-9, the array of possible values out of which a TinyURL can be constructed), autoincremented by MySQL with an initial value count of zero. What is a hash function? Imagine five buckets in a row. Now, starting with bucket one, we’ll drop one of 36 characters into the bucket, and check to make sure that for all other bucket sets out there, there isn’t a bucket that also has that particular character in the first bucket. If there is, we’d insert a character in the second bucket and run that comparison again, and so on and so forth . A hash is extremely efficient computationally, because instead of doing a tree comparison against all 62 million values, we’re incrementally comparing a set