Maybe this will clarify something for you:
Code:
#include <stdio.h>
#include <string.h>
#define SIZE 12
int main() {
char words[5][10] = { "word", "static", "delete", "goto", "continue" };
int i, j, len, base, key;
for (i=0;i<5;i++) {
base = 0;
len = strlen(words[i]);
// total the ascii value:
for (j=0;j<len;j++) base += words[i][j];
// the hash:
key = base%SIZE;
printf("%s has a key of %d (base was %d)\n", words[i], key, base);
}
return 0;
}
Since an isbn number is all numbers, you could calculate "base" differently. But you might as well do it this way if the number is in a string. It doesn't matter; what matters is that the base for calculating the key needs to be a single integer value.
SIZE is the size of the array you will use for the table, so "key" will always be between 0 and SIZE-1. That's the slot in the array you use for that word (or isbn number).
The size of the array is pre-determined and set, but the number of items in the table is not. It could be (generally, will be) more than the number of slots, but that is not the only reason for collisions. The reason I chose 12 here is because it creates a collision between "word" and "static". That means they will be going into the same slot (aka bucket).
There are a few ways to deal with collisions, one of the most common is to make the array an array of pointers to a linked lists. These lists are initially empty. Collisions are not to be avoided, they are an integral aspect of how a hash table works.