Hi all - im not looking for an entire answer to this question, or anyone to write a program for me (before anyone reminds me of the rules of the board ie. no homework will be done!!). Ive just started a C programming course and have just finished section on arrays and am now starting pointers. Ive been given questions to complete (one of which is below ). My problem is that i dont know where to start with it. I understand the principles and syntax used with arrays etc, but this question is causing me some frustration. Can anyone suggets a way of answering it?
Question:
"Hashing" is a method of storing data in an array so it can be retrieved in an efficient manner. This is done using a hashing algorithm to generate a "hash index" from a given data item (or "key"). The hash index is then used to select the particular array element that will store the data (similar to random files).
Write a program that uses 2 lists to store data. One list should be student names and the other list the course they are enrolled upon at college. Using students name as "key", the following algorithm will add together the ASCII values of each character in the name and then use the mod operator to convert the total into a range of 0 to MAxNum-1, where MaxNum is the sixe of the array.
eg using 24 for MaxNum, John Doe = J + O + H + N + D + O + E;
ie. 74 + 79 + 72 + 78 + 68 + 79 + 69 = 519
519 % 24 = 15
Im not sure as how i would go about answering this question. Any ideas at all?
Thans for your time (and patience!)