Educational Objectives: After completing this assignment, the student should be able to accomplish the following:
Operational Objectives: Add two methods to the class template HashTable<K,T,H>:
size_t HashTable<K,T,H>::MaxBucketSize () const; void HashTable<K,T,H>::Analysis (std::ostream& os) const;
conforming to the requirements and specifications given below.
Deliverables: One file:
hashtbl.cpp # contains implementations MaxBucketSize and Analysis
Note this is a slave file for hashtbl.h.
The official development, testing, and assessment environment is gnu g++ on the linprog machines. Code should compile without error or warning, when all warning flags are set.
Begin by copying the following files from the course directory into your proj2 directory:
LIB/proj2/hashtbl-stub.cpp # slave file - stubbed versions of Analysis and MaxBucketSize LIB/proj2/makefile # builds most executables LIB/proj2/proj2submit.sh # submit script LIB/tcpp/hashtbl.h # HashTable<> and HashTableIterator<>, except Analysis and MaxBucketSize LIB/tests/fhtbl.cpp # test harness for hash tables LIB/tests/hashcalc.cpp # calculates hash values interactively LIB/tests/hasheval.cpp # test focusing specifically on Analysis LIB/tests/rantable.cpp # creates randomtable data LIB/area51/fhtbl_i.x # linprog/Intel/Linux executables LIB/area51/fhtblSimple_i.x LIB/area51/rantable_i.x LIB/area51/hashcalc_i.x LIB/area51/hashevalKISS_i.x LIB/area51/hashevalMM_i.x LIB/area51/hashevalSimple_i.x
The executables in area51 are distributed only for your information and experimentation. You have the source code for these (except for hashtbl.cpp) and can build these to test your own code.
The file hashtbl.h is copied ONLY FOR YOUR CONVENIENCE. Note this file is NOT submitted to your portfolio, so any code you write must deal with this file as it currently exists in the course library at the time. It is a good idea to rename this to "hashtbl.header" just to ensure that your code is reading the file from the library.
Your file hashtbl.cpp should contain implementations of Analysis and MaxBucketSize.
Warning: Submit scripts do not work on the program and linprog servers. Use shell.cs.fsu.edu to submit projects. If you do not receive the second confirmation with the contents of your project, there has been a malfunction.
MaxBucketSize should return the size of the largest bucket in the hash table instance.
Analysis should result in a display (to the std::ostream passed in) as follows:
table size: 9997 number of buckets: 9973 nonempty buckets: 6326 max bucket size: 7 expected search time: 2.00 actual search time: 2.58 bucket size distributions ------------------------- size actual theory (uniform random distribution) ---- ------ ------ 0 3647 3659.9 1 3685 3669.0 2 1846 1838.9 3 608 614.4 4 145 153.9 5 37 30.9 6 4 5.2 7 1 0.7 8 0.1
This display shows the size of the table, number of buckets, number of non-empty buckets, max bucket size, expected search time [1 + (table size)/(number of buckets)], actual average search time [1 + (table size)/(number of non-empty buckets)]. Then a tabular printout of the bucket size distribution follows, showing the bucket size, actual number of buckets of that size, and the expected number for simple uniform hashing. The table print terminates for bucket size n when there are no buckets of size > n and the theoretical size is < 0.1.
Use the algorithms you developed in Assignment 2.
Thoroughly test your implementation for correct functionality using the provided test clients fhtbl.cpp and hasheval.cpp using a variety of tables you create with rantable.cpp. Be sure to test using variations:
The test harnesses fhtbl.cpp and hasheval.cpp are easily changed via comment/uncomment of typedefs to accomodate the variations in hash functions. The prime/non-prime number of buckets is a constructor argument (default value "true" meaning prime number of buckets).
Write a short summary paper giving your experience and lessons learned during the testing of variations as above. Turn this in as a pdf document under Assignment 4.
Use Assignment 2 # 3 as a check for internal consistency during Analysis.
Use Assignment 2 # 7 to calculate the theoretical bucket size distribution.
Use a vector sizeCount[k] to accumulate number of actual buckets of size k during a single pass through the buckets.