On 23.08.2006, at 17:11, Vlad Seryakov wrote:


In the case when ns_set has only few items, sequential search can be
much faster than hash overhead, so i am not sure about this one

Yes. This is true. But how would you know?
Say you have 100 element set and the thing
you are looking for is on the 1 place?

Obviously, the sequential search is instant.

But if the thing is at the end, then hash
*could* be faster.

The real problem is: set with a handful
of items (2-5). There the sequential search would
be almost always faster.

At some point (depending on the size of the
set), a hash lookup could pay off. the problem
is how to locate that point!

OTOH, how MUCH is the hash lookup slower for
a say, 10 or 20 elements set if, for example,
the thing is sitting in the middle? I believe
this is the question to answer... Perhaps
I should write some test code...

Cheers
Zoran


Reply via email to