in reply to Re: Check word presence WITHOUT hashes or grep
in thread Check word presence WITHOUT hashes or grep
++ IIRC from a math class back in the Cambrian, binary search is unbeatable on sorted data. Given a 500,000 word dictionary you will never have to do more than, let's see...
my $lookups = 0; my $words = 500_000; while ( $words > 1 ) { $words /= 2; $lookups++; } print $lookups, "\n";
...19 lookups -- meaning comparisons with some combination of lt, gt, ge, le, eq.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Check word presence WITHOUT hashes or grep
by gojippo (Novice) on Apr 30, 2008 at 05:43 UTC | |
by Your Mother (Archbishop) on Apr 30, 2008 at 05:49 UTC |