1. I answered your second point in my reply to matija
2. The input is a huge hash (HOH) table with the same data distribution you can see in the results table(second point).
3. The code I provided is an excerpt of a whole program, and the only thing is missig is the sorting. I am using strict and warnings.
4. I really don't know what else you need unless you want the whole program that is more than 6 pages