Hashing Course Codes

The University of Miami maintains a central WWW site where instructors can place instructional material. The course catalog for the College of Arts and Science lists 49 course codes. Devise a hash function that takes a course code and returns an index in the range 0-49. Implement your hash function in the program TestHash.cpp as the function HashFunction. If you run TestHash piping CourseCodes in as standard input, TestHash will report the number of collisions that your hash function causes for the course codes. Obviously zero collisions is optimal, but that may be hard to achieve.

If your function achieves less than 30% clashes you'll get 1.5% for the labtask, less than 45% clashes you'll get 1.0%, less than 60% you'll get 0.5%, and if you get more than 60% you'll get 0%.

Answer