CS 2420-20 Homework 9

Due: Thursday, February 17th, 2011 9:10am

Part 1 – Hashing Snakes

Use hash.c and hash.h from hashtable.zip. You will not need to modify them, and you don’t need to hand them in.

Represent a snake as a pointer to a snake structure type:

  typedef struct snake {
    char* name;
    double weight;
    char* food;
  } snake;

Implement comparison and hashing functions on snakes, where two snake structures represent the same snake if they have exactly the same name, weight, and favorite food.

Write tests that put and retrieve snakes in a hash table. The value to which each snake is mapped doesn’t matter; that is, the hash table acts as a “set” data structure to keep track of an unordered set of snakes.

Submit your work as snake.c.

Last update: Thursday, April 7th, 2011