Re: How hash tables work

From: Peter Piper (NoEmail_at_Email.com)
Date: 10/11/04


Date: Mon, 11 Oct 2004 09:46:14 +0000 (UTC)

Thanks J, I think maybe i have used the wrong phrase and i am trying to
produce a index table. Basically i need to sort my records by more than
one key field eg. Lastname, then firstname. Which i can do using a
binary sort/search but it becomes complicated when i use more than one
field. So i wanted to some how combine the key fields in to one field
and just search on that.
The way to combine the fields could either be by putting them together
as a string or create an integer hash from fields.
In my case it is possible to have duplicate hashes.

J French wrote:
> On Sun, 10 Oct 2004 13:22:27 +0000 (UTC), Peter Piper
> <NoEmail@Email.com> wrote:
>
>
>>Thanks for the information.
>>I was thinking of using hashes to help me search an array of records.
>>So instead of doing a binary search on the first key field in the
>>record, then the next key field, I create a integer hash using the two
>>fields and then search on that instead.
>>Is this a tried and tested method or is there a better approach to my
>>problem?
>
>
> Personally I would sort the records and do a binary chop
>
> However, I think what you are proposing is to produce a form of index
> field. It really depends on your data, it might or might not be
> suitable for representing as an integer.
>
> For example I store the 32 bit CRC of visited URLs in an array and
> scan that to decide whether a link is 'visited'. I tested 10,000 links
> and did not get a single duplicate CRC - but if I did get a duplicate
> in my case it would not matter much.
>
> My vote is always for the simplest approach, 'clever' things tend to
> produce obscure misbehaviour.



Relevant Pages

  • Re: How hash tables work
    ... Basically i need to sort my records by more than ... >one key field eg. ... >as a string or create an integer hash from fields. ... It helps if the underlying data is sorted. ...
    (alt.comp.lang.borland-delphi)
  • Re: How do I alphabetize a column but also have the corresponding cells move with the sort?
    ... rows without repeating the name in the same row in column A would cause them ... to sort incorrectly. ... If you want to have multiple rows for a definition, ... you need to have a matching value in the key field. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Inserting a "duplicate" record
    ... The SELECT works fine but it is not a true "duplicate" that I want, ... execute a sql statement something like: ... Dim strSQL as string ... Replace the single key field with a new value ...
    (microsoft.public.access.formscoding)
  • Re: SELECT . . . ORDER BY - SQL 2000 vs. JET 4
    ... mention locale. ... with this type of sort. ... I ended up doing a bubble-type sort on the key, and single inquiries ... use the ORDER BY statement, but, in the case of a key field, it may not be ...
    (microsoft.public.sqlserver.programming)
  • [OT] IDCAMS Error Counts?
    ... Originally the file was de-duped with a SORT on the key field and the SUM ... and the de-duping no longer occurs. ... REPRO'd there are records with duplicate key fields present and IDCAMS ...
    (comp.lang.cobol)