Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: [OT] pseudo-code for O(n log(n)) solution

Author: blass uri

Date: 05:36:35 06/26/00

Go up one level in this thread


On June 26, 2000 at 08:07:02, blass uri wrote:

>On June 26, 2000 at 05:47:28, Simon Finn wrote:
>
>>>static int compare(solution* a, solution* b)
>>>{
>>>    int i;
>>>    for (i = 0; i < SOLUTION_SIZE; i++)
>>>    {
>>>        if (a[i] < b[i]) return -1;
>>>        if (a[i] > b[i]) return 1;
>>
>>Sorry - that should be:
>>         if ((*a)[i] < (*b)[i]) return -1;
>>
>>etc.
>>
>>>    }
>>>    return 0;
>
>
>This compare is slow because it can take SOLUTION_SIZE steps and it often takes
>more than 1 step.
>
>I am not interested in the question if solution a is bigger or smaller than
>solution b but only in the question if it is different and in order to do it
>usually quickly I need to find hash number for every solution.

I can add that I thought to put the hash numbers in the right array but I
understand that I do not need to do it because I can use an array of pointers
lasthash[1048576] that gives me for every last 20 less significant digits of the
hash number the list of the numbers of solutions with the hash numbers that end
with these digits and in most of the cases the pointer will give me only 0 or 1
hash number if the number of solution is not bigger than 1000000 and I have not
enough memory for more than 1000000 solutions if I do not compress my solutions.

Uri



This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.