473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with double hashing table

69
I need to write a program that will determine the number of duplicates in a table of integers by using ordinary double hashing with initialization, I need to use double hashing with each entry in the hash table initialized to indicate that it is unused.
Nov 10 '06 #1
7 3852
sicarie
4,677 Expert Mod 4TB
I need to write a program that will determine the number of duplicates in a table of integers by using ordinary double hashing with initialization, I need to use double hashing with each entry in the hash table initialized to indicate that it is unused.
And did you have a question for us? Were you wondering the best way to go about this, was there a question with the hashing itself...?
Nov 10 '06 #2
saraSS
69
yes the best way to do it example code maybe thanks
Nov 10 '06 #3
sicarie
4,677 Expert Mod 4TB
yes the best way to do it example code maybe thanks
Cna you tell me how you'd do it, in a few sentences?

(Sorry, but I'm not going to give you the code... not only would that defeat the purpose of you learning it, but I am also too busy, though I will be more than happy to help you with it.)
Nov 10 '06 #4
saraSS
69
I have this hash but dont know how to make it a double hash
dont know how

main()
{
char str[81];
int hash,i;

while (1)
{
scanf("%s",str);
hash=0;
for (i=0;
str[i]!=0;
i++)
hash=(hash*10+str[i])%1005;
printf("%s => %d\n",str,hash);
}
Nov 10 '06 #5
saraSS
69
when I use the qsort I get some duplicates and I'm trying to do the same thing with double hashing but I get no duplicates what I'm doing wrong?
void duplicates_Dhashing(int seed,int n)
{
int *table,i,duplicates,key;
unsigned h,h2;
n=nextPrime(n);
table=(int*) malloc(n*sizeof(int));
if (table==NULL)
{
printf("choked in duplicates_qsort()\n");
exit(0);
}
for (i=0;i<n;i++)
table[i]=-1;
srandom(seed);
for (i=0;i<n;i++)
{
key=abs(random());
printf("%d \n",key);
h=(key % n);
h2=(( key % ( n - 1 )) + 1);
while (table[h]!=-1)
h = ( h + h2 ) % n;
table[h] = key;
}
duplicates=0;
for (i=1;i<n;i++)
if (table[i-1]==table[i])
duplicates++;
printf("%d duplicates \n",duplicates);

}
Nov 14 '06 #6
saraSS
69
I still need help with this double hashing table when I do a qsort() I get some duplicates but with the double hashing I get 0 duplicates
Nov 17 '06 #7
saraSS
69
can somebody help me ? my double hashing loop is not working it looks like should be working but I dont know
for(i=0;i<m;i++)
{
key=abs(random());
h=((key+i)%m);
h2=(1+(key%(m-1)));
h=((h+(i*h2))%m);
if(table[h]==-1)
table[h]=key;
}
Nov 20 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Paul Schouten | last post by:
Hey, Currently im working on a project where a dynamic database is created in memory, the database can be of any size both in the amount of rows aswell as in the amount of columns. The database...
9
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM,...
11
by: Wm. Scott Miller | last post by:
Hello all! We are building applications here and have hashing algorithms to secure secrets (e.g passwords) by producing one way hashes. Now, I've read alot and I've followed most of the advice...
14
by: Ron M. Newman | last post by:
Hi group, I need similar functionality I'm getting from the hashtable, but without the value .all I need is keys. this of course negates the need for "hashing", but I wanted to know if there's a...
7
by: webgyrl | last post by:
Hi, I am helping a musician friend of mine with his profile and I found a cool layout on Nas' MySpace page. I changed some things and re-did the graphics and I basically popped my Image URLS...
22
by: j1mb0jay | last post by:
I have had to create a simple string encryption program for coursework, I have completed the task and now have to do a write up on how it could be improved at a later date. If you could look...
0
by: s.phonologies | last post by:
Hi friends, I am Sumit problem in C Language I have created a program to store int data by the HASH() my hash function for generate hashkey: int HASH(data) { return data%10;
11
by: January Weiner | last post by:
Hello, I need to use a hashing function for relatively short strings (roughly 16 characters or less). The data that needs to be accessed via hash is just a simple int. I just need to look up...
15
by: Vinodh | last post by:
I am reading about hashing techniques. The map data structure available in C++ STL uses hashing techniques?
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.