Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: hash tables question

Author: blass uri

Date: 02:52:09 06/25/00

Go up one level in this thread


On June 25, 2000 at 05:14:10, Andrew Dados wrote:

>On June 25, 2000 at 03:27:07, blass uri wrote:
>
>>Can somebody post a C program that translates arrays to 32 bits integers when
>>usually different arrays get different numbers and also translates it in a way
>>that it is easy to find if the 32 bits integer is new?
>>
>>I think that this is the idea behind hash tables
>>
>>I need it for my program that I use to solve equations and inequalities.
>>
>>I have an array possolution[256][100000] and
>>I need to check if the possolution[256][i] is not identical to
>>possolution[256][j]
>>for all j<i(I do i++ only if it is not identical).
>>
>>If I can calculate the hash entry of possolution[256][i] and discover in a short
>>time that the hash entry of possolution[256][i] is different than the hash entry
>>of possolution[256][j] for j<i it will save my program a lot of time
>>
>>I need to know also how to do it in C with O(log[i]) steps and not in O(i) steps
>>and I know only how to do it theoretically in O(log[i]) steps but I do not know
>>how to do it in C because I do not know how to push an array forward(if I have
>>an array hash[100000] I do not know how to do for (i=35000;i<90000;i++)
>>hash[i]=hash[i+1] in a short time)
>
>if you treat hash as a pointer to array, just decrement its start point by
>SizeOf(hashentry), then remember then it has moved, so you don't access hash[i],
>but rather hash[i+offset]

I understand that I can do
for (i=0;i<99999;i++)
hash[i]=hash[i+1] by treating hash as a pointer but the problem
is what to do if I want to do for (i=30000;i<90000;i++) hash[i]=hash[i+1]
without changing hash[i] for i<30000.

The reason that I want to do is that hash is an array of numbers in increasing
order and I want to do hash[30000]=newnumber in order to keep the right order of
numbers because I need the right order to help me to search if a new number is
equal to one of the numbers in the hash table.

I guess that there is a simple way to do it in C and this is what I ask for.

I also ask for a simple way to translate a sequence of integer numbers to one
integer when different sequences usually get different numbers.

Uri



This page took 0 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.