In the past, I did a little exercise about the hash table, but the user specified the size of the array, and the structure was like that (so the user each time entered a number and a word as input)
struct data
{
int key;
char c[20];
};
So, it was pretty simple, since I knew the size of the array, and also the user said how many items he would give as input. The way I did it was
- Storing the keys that the user gave me
- find the array of position [hashed (key)] in the array
- If it were empty, I would put the data there
- If this were not so, I would put him in the next free position that I would find.
But now I need to make an inverted index, and I'm doing a search, so I can make a hash table. Thus, words will be collected from approximately 30 txts, and there will be so many. So in this case, how long should the array be? How can I hash words? Should I use hasing with an open address or chaining. In the exercise, we can use the hash table as if we were to find it on the Internet. but I prefer to understand and create it myself. Any hints will help me :)
In this exerice (inverted index using a hash table), the structures are as follows. the data type is the type of hash table that I will create.
struct posting
{
string word;
posting *next
}
struct data
{
string word;
posting *ptrpostings;
data *next
};
source
share