Project 6: Hash Table

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

Revision dated 06/24/19

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:

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
wordbench4.h    # defines wordbench class using hashtable associative array 
wordbench4.cpp  # implements wordbench class using hashtable associative array 
wordify.cpp     # copy of file from project 3,4,5
makefile.wb4    # builds wb4.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
    main_wb4.cpp        # driver for wordbench4
    deliverables.sh     # 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
    LIB/area51/wb4_i.x            # wordbench4
    

    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. As an example client of hash tables, produce wordbench 4 which has behavior identical to wordbench 3, except that tabular output is no longer in dictionary order.

  8. The makefile makefile.wb4 builds the hash table client wb4.x.

  9. 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. Once you are completely confident in your hash table code, create wordbench4.h and wordbench4.cpp (by revising copies of the wordbench3.h and wordbench3.cpp, rspectively) that gives an un-ordered version of WordBench.

  7. Identical Output
    Output from your project should be identical to that produced by the area51 examples, with these exceptions: HashTable::Analysis() and HashTable::MaxBucketSize() are functional in the area51 examples and wb4_i.x displays the underlying map technology being used.

Hints