Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / June 2008

Tip: Looking for answers? Try searching our database.

Simple collision question

Thread view: 
puggid@googlemail.com - 29 May 2008 21:00 GMT
I was wondering if someone tell me how I go about calculating
collision rates for a "key" that is 2 characters (lowercase alpha
only) long?

I realise it's 26x26 but if I generate two random numbers between 1-26
is that all that's involved? So each time I generate this key, I have
a 1/676 chance of a collision?

Thanks for the help
Tarin Gamberini - 30 May 2008 21:44 GMT
puggid@googlemail.com ha scritto:
[cut]
> I realise it's 26x26 but if I generate two random numbers between 1-26
> is that all that's involved? So each time I generate this key, I have
> a 1/676 chance of a collision?

I think that what you said is right if your random source gives numbers
uniformly distributed. Check out this
http://en.wikipedia.org/wiki/Uniform_distribution_%28discrete%29

So, how your random source generates numbers? Check out this
http://en.wikipedia.org/wiki/Random_number_generator too.

Bye,
Tarin

Signature

Tarin Gamberini
www.taringamberini.com

Roedy Green - 02 Jun 2008 10:47 GMT
>I was wondering if someone tell me how I go about calculating
>collision rates for a "key" that is 2 characters (lowercase alpha
>only) long?

Think about it this way.

To have no collisions with a perfect hash.

for 2 keys and N slots, my odds are 1- (N-1)/N since all slots but 1
are good.

when I add another key, the odds that one will be good too is

1- (N-2)/N.

The odds of all 3 keys going to different slots are:

[1- (N-1)/N] * [1- (N-2)/N]

You should see the pattern.

You can compute this iteratively or factor it to use factorials which
just mask the iteration.
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.