Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Foundations of algorithms chp 8 # 18 Question #8: A rehashing known as double ha

ID: 3581898 • Letter: F

Question

Foundations of algorithms chp 8 # 18

Question #8: A rehashing known as double hashing uses a secound has function in case a clash. If the first hash function is h and the second hash function is s, the entire sequence of positions of the hash table that will be checked for an available bucket is given by the following equality, where pi, is the ith position in the sequence:

pi(key)=[(k(key)+i x s (key) -1)% table_size] +1

uses a is h and a hash function in case the first hash function the second hash function s, of a clash. If hash table that will be checked the entire sequence of positions of the for an available bucket is given by the following equality, where pi is the ith position in the sequence: pi (key) [(k (key)+ i x s (key)- table-size 1 returns the remainder when the first operand is divided by the second Define a second hash function for the problem instance of Figure 8.8 and show the table after all the keys have been inserted into the hash table.

Explanation / Answer

#include #include #define MIN_TABLE_SIZE 10 using namespace std; /* * Node Type Declaration */ enum EntryType {Legitimate, Empty, Deleted}; /* * Node Declaration */ struct HashNode { int element; enum EntryType info; }; /* * Table Declaration */ struct HashTable { int size; HashNode *table; }; /* * Function to Genereate First Hash */ int HashFunc1(int key, int size) { return key % size; } /* * Function to Genereate Second Hash */ int HashFunc2(int key, int size) { return (key * size - 1) % size; } /* * Function to Initialize Table */ HashTable *initializeTable(int size) { HashTable *htable; if (size table[pos].info = Legitimate; htable->table[pos].element = key; } } /* * Function to Rehash the table */ HashTable *Rehash(HashTable *htable) { int size = htable->size; HashNode *table = htable->table; htable = initializeTable(2 * size); for (int i = 0; i table[i].element; if (!value) cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote