Mr. Bad wrote:
> In order, we checked 8 keys, instead of 14:
>
> number        1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
>
> check order   1  2     3           4           6  8  7     5

So in phase 1 you're checking 2^0, 2^1, 2^2, 2^3 and so on. A devilish idea
comes to my mind... why not take the scheme to the next level? Check

2^(2^0) = 2^1 = 2
2^(2^1) = 2^2 = 4
2^(2^2) = 2^4 = 16
2^(2^3) = 2^8 = 256
...

Of course, before going to phase 2, you will then have to find the exact
exponent (eg 2^3).

If the index is larger than 10 or so, this actually saves a few accesses.

Looking at it this way, it all seems to depend on how large you expect the
final number to be (in the tens, hundreds, thousands or higher?).

This is a nice mathematical problem - for a given probability distribution
of the current maximum index, find the most efficient algorithm to find the
maximum. I used to study math, but that's a while ago ;-/

-Stefan



_______________________________________________
Devl mailing list
Devl at freenetproject.org
http://lists.freenetproject.org/mailman/listinfo/devl

Reply via email to