Here's the answer; we can define hashtable_get_bucket, and
it takes two inputs, the hash table, we'll
call that htable, and the key, which is
the word we're looking for. And to find the
bucket, well, we're going to use hash_string. We're going to
pass in the same word, the keyword, that's the
input key. The number of buckets is the
length of this table, so we're going to call hash_string,
passing in the key. And as the second input, we need
the length of the table, that's the number of buckets. So
that will get us a number which is the index of
the bucket we want. To get that bucket, we need to
use that as the index to select that element from htable,
and then we want to return the results. So that's all
we need to find the bucket. Let's look at that in
the Python interpreter. So here's the code we have so far.
We have the hash string procedure we defined that maps
the key word and a number of buckets to the position
where that should occur in the hash table. We have
the make_hashtable procedure that creates an empty table with that number
of buckets. And now we have the hashtable_get_bucket procedure that
takes a hash table and a key. And give this the
element of the hash table which is where that key would
belong using that hash string function to find the right position.