Answered You can hire a professional tutor to get the answer.

QUESTION

Hashing provides an excellent table implementation technique with expected access times independent of the table size.

Hashing provides an excellent table implementation technique with expected access times independent ofthe table size. We implement a polymorphic instance of the table data type using separate chaining hashingtogether with the move-to-the-front heuristic to determine it’s performance experimentally. Your assignmentis to create the table implementation in C++.Table Data TypeHere is a portion of the Table header describing the functionality you must provide within your implemen-tation.1: typedef struct { double successful[2] , unsuccessful[2] ; } Perform ;2:3: template <class DATA>4: class Table {5: private :6:7: // your data structure implementation choices here8:9: public :10: explicit Table ( unsigned int size = 5 ) ;11: void clear ( ) ;12: bool insert ( DATA & data ) ;13: bool remove ( DATA & data ) ;14: bool access ( DATA & data ) const ;15: Perform perform ( ) const ;16: list<DATA> & getOne ( unsigned int i ) ;17: } ;The explicit Table constructor, with the default parameter, creates an empty table for DATA objects. Theexplicit “modifier” avoids type conversion without explicit type casting. The default parameter assures atable of size five will be built unless another size is explicitly requested.The clear method resets the table data structure to its initial state so it contains no DATA objects. Thedestructor is called for each object.The insert method includes the DATA object within the table using separate chaining hashing and returnstrue if successful. The method returns false if a duplicate is found. The object is included at the “back” ofthe appropriate list.The access method locates the object within the table and sets data to this value as well as returning true.Otherwise, false is returned. The data parameter initially contains only the key for the desired record. Thismethod implements the move-to-the-front scheme; the STL erase function is a suggestion in this context.The delete method removes the object from the table and sets data to this value as well as returning true.Otherwise, false is returned. The data parameter initially contains only the key for the to be removed record.The perform method determines the average successful and unsuccessful search lengths for the table andreturns them via a Perform structure. The average successful search length is determined for all the recordswithin the table. The average unsuccessful search length is determined from the lengths of the chains. Thesevalues are stored in perform successful[0] and unsuccessful[0]. The expected successful and unsuccessfulsearch lengths are calculated and returned in successful[1] and unsuccessful[1] respectively.The getOne method returns a list<DATA> reference providing access to the ith list. This is not a “normal”table method but it is useful in the course.The private portion within the class Table declaration provides our implementation hiding/security mech-anism.version 2Main ProgramsThere are four main programs main0, main1, main2, and main3 for your use. Program main0 demonstratesthe example from page 40 of the notes. The program main1 allows you to create performance statistics forseparate chaining. The main2 program tries to insert a duplicate record as well as determining where arecord is stored. Finally program main3 stores more realistic records with a useful hash function. There isan optional makefile for these programs; the makefile assumes your table.hpp and table.cpp files are in thesame directory.Hints1. Begin by trying to build very small tables with only a record or two. You can modify the main0.cpp programto build such tables.2. Your class Table data structure must be “private.”What to Turn inYou are to submit the following files: table.cpp, table.hpp, README as a tar file – affectionately referredto as a “tar-ball.” Your table.hpp is to differ from the one in the homework folder only within the privatesection.//Sample Output//main0 outputlist 00: 12 pig1: 18 apelist 10: 16 dog1: 22 yaklist 20: 20 cowaverage ssl 1.400000 average usl 1.666667list 00: 12 pig1: 18 apelist 10: 22 yak1: 16 doglist 20: 20 cowlist 00: 12 piglist 10: 22 yak1: 16 doglist 20: 20 cowaverage ssl 1.250000 average usl 1.333333// main1 outputexpectedusl0.000000 1.000000 1.000000 1.000000 1.000000 Separate Chaining0.100000 1.000000 1.000000 1.000000 1.000000 Separate Chaining0.200000 1.045000 1.050000 1.009000 1.010000 Separate Chaining...9.700000 5.811753 5.800000 9.700000 9.700036 Separate Chaining9.800000 5.835000 5.850000 9.800000 9.800033 Separate Chaining9.900000 5.912525 5.900000 9.900500 9.900030 Separate Chaining10.000000 5.938050 5.950000 10.000000 10.000027 Separate Chaining//main2 outputlist 0list 10: 23451: 67812: 3589list 20: 12341: 23422: 2343: 9982list 30: 235record 6781 is presentrecord 7766 is not presentrecord 98 is not presentduplicate record attempted: 6781average ssl is 2.125000 average usl is 2.250000expected ssl is 1.875000 expected usl is 2.100113list 0list 10: 67811: 23452: 3589list 20: 12341: 23422: 2343: 9982list 30: 235list 0list 1list 2list 3//main3 outputlist 00: name: alex kronkov zip: 56789list 10: name: beth smith zip: 920141: name: darrell cruz zip: 234552: name: willie yuu zip: 12345list 20: name: herb jones zip: 92093list 30: name: alan knox zip: 789011: name: patti bliss zip: 164282: name: jehan roma zip: 345673: name: diane lake zip: 164284: name: bev tuxin zip: 92014average ssl is 2.300000 average usl is 2.500000expected ssl is 2.125000 expected usl is 2.556314//MyData.hpp#include <iostream>#include <string>#include <cmath>using namespace std ;class MyData {

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question