Justtechjobs.com Find a programming school near you






Online Campus Both


php4-beta | 200004

Re: [PHP4BETA] Zend hash functions enchantments [PATCH] From: Zeev Suraski (zeev <email protected>)
Date: 04/06/00

On Thu, 6 Apr 2000, [ISO-8859-1] Jerry Lundström wrote:

> On Wed, 5 Apr 2000 18:01:19 +0200 (IST), Andi Gutmans <andi <email protected>> wrote:
>
> >I don't think your patch is correct unless I'm missing something.
> >Two different strings can have the same length and the same hash value. It
> >doesn't seem as if your implementation works in this case.
>
> Are you sure about this?

Absolutely sure.

> If it is so then then hash algo seams a little bit weak because that should
> not happen. You shouldn't get two diffrent strings with the same hash value.

Any general-purpose hashing algorithm may have multiple entries with the
same hashing value - it's almost by definition.

For specific cases, when you know in advance exactly what entries you may
have in the hash, you can create a data structure called a 'perfect hash',
in which each hash value corresponds to exactly one possible entry. It's
not possible to do when your 'domain' is infinite, and the the number of
possible strings in the world is, as you know, infinite.

Zeev

-- 
Zeev Suraski <zeev <email protected>>
http://www.zend.com/

-- PHP 4.0 Beta Mailing List <http://www.php.net/version4/> To unsubscribe, e-mail: php4beta-unsubscribe <email protected> For additional commands, e-mail: php4beta-help <email protected> To contact the list administrators, e-mail: php4beta-admin <email protected>