Question: Write a program in C to find Anagrams with Hashtables The word file you need to read in to find anagrams with: words.txt words.txt contains

Write a program in C to find Anagrams with Hashtables

The word file you need to read in to find anagrams with: words.txt

words.txt contains a lot of words, you need to read it one by one sort it and store it as key into the hashtable.

When you read in the file, be sure to malloc every word.

Must contains appropriately-named methodsCreate, Destroy, Insert, Get, and Print

Feel free to use other add other funtcions.

Write a program in C to find Anagrams with Hashtables The word

struct hashtableInfo { int num_buckets; int num_elements; LinkedList* buckets; }; typedef struct hashtableInfo* Hashtable; int HashKeyToBucketNum (Hashtable ht, uint64_t key); typedef struct { uint64_t key; // the key in the key/value pair void *value; // the value in the key/value pair } HTKeyValue, *HTKeyValuePtr; typedef void(*ValueFreeFnPtr) (void *value); Hashtable CreateHashtable(int num_buckets); void DestroyHashtable(Hashtable ht, ValueFreeFnPtr value_free_function); int Insert InHashtable(Hashtable ht, HTKeyValue kvp, HTKeyValue *old_kvp); int LookupInHashtable(Hashtable ht, uint64_t key, HTKeyValue *result); int NumElems InHashtable (Hashtable ht); void PrintHashTable(); uint64_t FNVHash64(unsigned char *buffer, unsigned int len) { static const uint64_t FNV1_64_INIT = Oxcbf29ce484222325ULL; static const uint64_t FNV_64_PRIME = 0x100000001b3ULL; unsigned char *bp (unsigned char *) buffer; unsigned char *be = bp + len; uint64_t hval = FNV1_64_INIT; while (bp >= 8; } return FNVHash64(buf, 8); } struct hashtableInfo { int num_buckets; int num_elements; LinkedList* buckets; }; typedef struct hashtableInfo* Hashtable; int HashKeyToBucketNum (Hashtable ht, uint64_t key); typedef struct { uint64_t key; // the key in the key/value pair void *value; // the value in the key/value pair } HTKeyValue, *HTKeyValuePtr; typedef void(*ValueFreeFnPtr) (void *value); Hashtable CreateHashtable(int num_buckets); void DestroyHashtable(Hashtable ht, ValueFreeFnPtr value_free_function); int Insert InHashtable(Hashtable ht, HTKeyValue kvp, HTKeyValue *old_kvp); int LookupInHashtable(Hashtable ht, uint64_t key, HTKeyValue *result); int NumElems InHashtable (Hashtable ht); void PrintHashTable(); uint64_t FNVHash64(unsigned char *buffer, unsigned int len) { static const uint64_t FNV1_64_INIT = Oxcbf29ce484222325ULL; static const uint64_t FNV_64_PRIME = 0x100000001b3ULL; unsigned char *bp (unsigned char *) buffer; unsigned char *be = bp + len; uint64_t hval = FNV1_64_INIT; while (bp >= 8; } return FNVHash64(buf, 8); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!