Dummy’s Guide to Url redirections…
Something is amiss with the way tinyUrl shortens its URLs
I tinyURL-ify this URL http://ibnlive.in.com/news/vijay-mallaya-buys-gandhi-items-f
or-18-mn/86943-3.html and I get this output http://tinyurl.com/dfqtql . For some reason, rather just out of curiosity I repeat the process and this time I get a new output http://tinyurl.com/78llkl
Something is amiss here.
So lets quickly try to guess how tinyurl works.
There are a class of functions called hashing functions, which is a m x n mapping, where m > n. So a hash operation is performed on an url and the output is stored in what is called a hash table.
You are taught in elementary classes in Data Structures that a hash table lookup is O(1) operation that is to say, it is largely independent of the number of entries.
Now we get back to the hash function, since m > n a hashing function is not one to one, rather is many to one.
Now because of this more than one url will hash on to one value. Therefore while storing the key(the hashed value) in your hash table you would also store the url, where you would want to redirect the user to.
Now lets see what would happen when someone lands at your page with an url like http://tinyurl.com/abcdef. Simple all you do is look up abcdef and the value you get is the url where you would redirect an user to.
Now lets see when an user comes to us with a request to tiny-ify an url http://longweblink.com.
You hash the url, and the value you get you look it up in the hash table( o(1) operation) and if the lookup fails you insert the key and url into the hash table and return the key to the user as the shortened url.
By doing this what are you ensuring? Simple. When two different users come to you with http://longweblink.com you are ensuring that you return the same shortened url to them. Therefore saving on duplicate links.
But what happens with tinyurl.com? when an user comes to tinyurl with the same http://longweblink.com, each time he gets a new shortened url. Every time. Yes a new url everytime.
Now lets see what kind of urls are shortened. My guess would be long urls of course… but basically interesting sites which you want to share with somebody else. And knowing the internet, there is a always a very high probability that more than one person finds a link interesting and usually this commonality numbers are pretty huge.
So doesnt it make sense for tinyurl.com to eliminate duplicates and assign shortened urls in the manner that we have learnt in this article this far?
I see only one reason…tinyurl.com wants to overstate numbers!!! if it has not done already, very soon you would see a proclamation saying - A billion urls shortened by tinyurl.com! Now that you have read this article you know what to do dont you? Yes, discount those figures!
Addendum: tinyurl.com has a nifty feature called ‘enable previews’ … please enable that. This would ensure that any redirection is first notified to you before its done. This is a MUST to prevent malice to your computer. An evil guy can tinyurlify http://thiswebsitewilldobadthingstoyourcomputer.com and he would get an url http://tinyurl.com/random and the unsuspecting you will click on it…hallelujah…
PS:
1. Tried the functioning of another url shortener http://is.gd and this site works good, no duplication - http://is.gd/mbfM
2. Tried the functioning of another url shortener http://snipurl.com and this site works good, no duplication - http://snipurl.com/dae7k
3. Tried the functioning of another url shortener http://bit.ly and this site works good, no duplication - http://bit.ly/2QBop
PS2: If you were asked to monetize the services of http://tinyurl.com how would you do so? Leave your comments.
PS3: Something definitely amiss…now two urls hashed to the same value at tinyurl.com!!!(That would nullify my accusation) This still doesnt explain http://tinyurl.com/dfqtql and http://tinyurl.com/78llkl
Maybe I should sleep. Good night

