Help understanding a program - NOT ASKING ANYONE TO DO IT

Hi Everyone,

I've recently been assigned a program due this coming week on hash tables. However, the teacher is out of the office until then and despite me asking her, she hasn't been in touch. I am therefore turning to you guys to help me understand what I have to build!

This is the assignment sheet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Your assignment is to implement two versions of a hash table in two separate programs, using the code in Chapter 5 of your book.  Link to the author’s webpage: http://users.cis.fiu.edu/~weiss/dsaa_c++4/code/ .  Note that to instruct the compiler to use the new standard for C++11, you have to add an option to the compile line, as in
g++ -std=c++0x TestAvlTree.cpp

The first program should use separate chaining to handle collisions. The second program should use linear probing.  Both programs should have the following features:
	•	The hash table is implemented in a HashTable class.  This class has at least the following functions. 
	o	a constructor function
	o	insert
	o	remove
	o	contains
	o	makeEmpty
	o	print
	o	myhash 
	o	rehash (for second version of program)
•	The hash table contains instances of the Symbol class.  A Symbol has a name of type string and a type of type int.¬
•	Use the name as the key for the hash table.
•	Read the symbol data from an external file called “symbols.txt”.  I’ll give you a file to use.  You can hard-code the name of the file into your program.
•	Implement the hash function of your choice.
•	Allow the user to indicate the hash table size at the beginning of the program.  
•	Have your program print out a message each time a collision occurs.
•	Have your program print out a message each time a new table is being created.
•	Print out the hash table after all the symbols have been read.


Now what I don't understand is the whole "Symbol" class business. I just don't see how that comes into play here. I recognize that for separate chaining I must use a Linked List, however, I just don't see why I couldn't simply read in the text file, store the contents in a vector, hash the name for the key, and insert into the table.

My teacher is insistent on having a Symbol class.

Does anyone understand this better than I do?

Please realize by NO MEANS am I asking you to code this, etc... I'm just asking for clarity as this has been a roadblock for me.

Thank You!
It looks like you need to store Symbol objects in your hash table using only name field for purpose of hashing (Means that two Symbols with same name and different ints will have same hash. Probably needed to force hash collision)
Topic archived. No new replies allowed.