Project 6: Hash Table

HashTable and associated Iterator class templates implementing the Unordered Table and Unordered Associative Array ADTs

Revision dated 06/05/18

Educational Objectives: After completing this assignment, the student should be able to accomplish the following:

Background Knowledge Required: Be sure that you have mastered the material in these chapters before beginning the assignment:
Introduction to Sets, Introduction to Maps, Hashing, and Hash Tables.

Operational Objectives: Implement the class templates HashTable<K,D,H>, ConstHashTableIterator<K,D,H>, and HashTableIterator<K,D,H>.

Deliverables: Three files:

hashtbl.h     # contains HashTable<> , ConstHashTableIterator<> ,  and HashTableIterator<> template classes (including implementations)
makefile.ht   # builds all: fhtbl.x fhtblKISS.x fhtblModP.x fhtblMM.x fhtblSimple.x rantable.x hashcalc.x
log.txt       # your project work log

Procedural Requirements

  1. The official development/testing/assessment environment is specified in the Course Organizer.

  2. Create and work within the subdirectory ~/cop4530/proj6.

  3. Do your own work. Variations of this project have been used in previous courses. You are not permitted to seek help from former students or their work products. For this and all other projects, it is a violation of course ethics and the student honor code to use, or attempt to use, code from any source other than that explicitly distributed in the course code library, or to give or receive help on this project from anyone other than the course instruction staff. See Introduction/Work Rules.

  4. Begin by copying all files from the directory LIB/proj6 into your proj6 directory. At this point you should see these files in your directory (and possibly others):

    fhtbl.cpp           # test harness for hash tables
    rantable.cpp        # random table generator
    hashcalc.cpp        # hash calculator
    hashtbl.start       # starting point for hashtbl.h
    deliverables.ht     # submission configuration file
    

    Then copy these relevant executables:

    LIB/area51/fhtblKISS_i.x      # fhtbl_i.x with KISS hash function
    LIB/area51/fhtblMM_i.x        # fhtbl_i.x with MM hash function
    LIB/area51/fhtblSimple_i.x    # fhtbl_i.x with Simple hash function / non-prime flag
    LIB/area51/hashevalKISS_i.x   # hash analysis with KISS
    LIB/area51/hashevalMM_i.x     # hash analysis with MM
    LIB/area51/hashevalSimple_i.x # hash analysis with Simple/non-prime
    LIB/area51/rantable_i.x       # random table generator
    LIB/area51/hashcalc_i.x       # hash function calculator
    

    The executables in area51 are distributed only for your information and experimentation, as well as the exercises in the lecture notes. You will not use these files in your own project, but they will help you understand hashing and hash tables and are very useful in preparing for the final exam. When you have questions about behavior of either hash tables or the router simulation, use these executable to find the answer.

  5. You are to define and implement the template classes HashTable<K,D,H> and its associated iterator classes ConstHashTableIterator<K,D,H> and HashTableIterator<K,D,H>. Place definitions and implementations in the file hashtbl.h. Note that a lot of this work is already done in the startup file.

  6. The makefile makefile.ht builds the supporting test infrastructure for hash tables. You can test different targets individually by naming them as an argument to the make command.

  7. Submit the assignment using the script LIB/scripts/submit.sh.

    Warning: Submit scripts do not work on the program and linprog servers. Use shell.cs.fsu.edu to submit assignments. If you do not receive the second confirmation with the contents of your assignment, there has been a malfunction.

Code Requirements and Specifications - HashTable and HashTableIterator

  1. Implement the HashTable<K,D,H>, ConstHashTableIterator<K,D,H>, and HashTableIterator<K,D,H> classes as defined in the file LIB/proj6/hashtbl.start using the implementation plan discussed in the lecture notes. (Search for "TBS" to locate the places where additional code is required.)

  2. Be sure not to change the definition of HashTable<> from that distributed in LIB/proj6/hashtbl.start.

  3. Const iterators are read only and can be used in a const environment. Whereas the non-Const iterators are read/write. Read/write iterators for associative data structures would normally be a problem, because a client program could modify elements in a way that might compromise the internal consistency of the data structure. Just as for Map, our read/write iterators can be used to modify data only, not keys, thus making it impossible to use them to compromise the table structure.

  4. Place all hash table code, including definitions and implementations for both hash table and hash table iterator, in the file hashtbl.h.

  5. Thoroughly test your implementation for correct functionality using the provided test client fhtbl.cpp and tables generated with rantable.cpp. Test with small and large tables (at least 100,000 entries).

  6. Identical Output
    Output from your project should be identical to that produced by the area51 examples.

Hints