In either case, you should already know how to look for k. In the worst case, all of the keys will hash to the same place. The worst-case time is the same as for lookup, since the value has to be found before it can be deleted. If the number of items to be stored is not known, then you can always plan to expand the hashtable whenever it gets too full. Let's assume that the keys are strings.
Most programming languages provide a way to convert individual characters to integers.
First, though, let's think about which characters in the string we want to use. Remember that we want our hash function to be efficient , and to map different keys to different locations in the hashtable. For keys that have more than N characters, there is also a question of which characters to choose. To simplify our discussion, let's assume that we know the keys won't be too long, so our hash function can simply use all of the characters in the keys. Add the integer values of all of the characters.