Suppose a user-defined hash function has the following prototype.
size_t hash( const Thing& x );
Suppose further that it produces values of size up to 32 bits. To use this function with a hash table of size m, the user should
Consider the following outline of a memoized function.
int f( int x ) { ... }
How many steps does it take to make 10000 calls to f on input x = 1000?
Consider the following definition of a function hash.
size_t hash( const char *str ) { size_t h = 0; for( ; *str != '0'; str++ ) h = h*256 + *str; }
What, if anything, is wrong with hash as a hash function for null-terminated strings?