I have a hashAry. I want to fill it with data from a file using hash function modulus division. Can I search for the index in the hashAry until it matches with the address from modulus division?
I have a hashAry. I want to fill it with data from a file using hash function modulus division. Can I search for the index in the hashAry until it matches with the address from modulus division?
You just want to search the hash table?
-PreludeCode:/* Search a table of strings */ char *search ( const char *find ) { int i = hash ( find ); while ( hash_table[i] != NULL ) { if ( strcmp ( hash_table[i], find ) == 0 ) return hash_table[i]; else i = ( i + 1 ) % max_elements; } return NULL; }
My best code is written with the delete key.
What if the hash array is an array of nodes?
>What if the hash array is an array of nodes?
Just add an extra level of indirection for the comparison.
-PreludeCode:struct node search ( const char *find ) { int i = hash ( find ); while ( hash_table[i] != NULL ) { if ( strcmp ( hash_table[i].something, find ) == 0 ) return hash_table[i]; else i = ( i + 1 ) % max_elements; } return empty_node; }
My best code is written with the delete key.