Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For 0 points, implement hashtable_qp.cpp from the hashtable2_handout. This will form the base for your work. Make sure the code compiles and runs as expected.

For 0 points, implement hashtable_qp.cpp from the hashtable2_handout. This will form the base for your work. Make sure the code compiles and runs as expected. You only need the hash function for string data.

For 60 points, modify the hash_table class code as follows:

Augment the hash_table class with a private subclass called "key_line" which uses a string to hold a key (word) and a vector of integers to keep track of all the line numbers where the key is found in the input file. You will neither need to implement a constructor or a destructor (the defaults will do fine), but you must implement a key_line::inuse() member function that indicates whether the object holds a key or not. You will also need to overload the comparison operator, i.e., operator==(). That's it for key_line which should be based on a struct instead of a class to make it readily available to the hash_table member functions.

Remove all template references used by the hash_table class which should be modified to explicitly use the key_line subclass. This includes making member functions qprobe(), insert(), and resize() all use key_line::inuse() when checking to see if an entry exists.

Modify the hash_table::insert() function to add a key if not present in the hash table. Update each key_line object to have it maintain a sorted list of all unique line numbers for it (no That is, search the line number vector mentioned above and if not found, add the new line number at the end of the list. Use std::find() to carry out the search.

Add a public member function hash_table::find() that returns a constant reference to the vector of line numbers associated with the hash table entry for a given key. If the key is not found, a reference to an empty vector is returned. You deal with this in the main program.

image text in transcribed image text in transcribed

Hashtable: class code (60 points) *20: key_line subclass definition and implementation 20: hash_table use of key_line instead of template data 20: hash table::insert) and hash_table::find) updates Executable output examples Note: Blank lines have been inserted below for readability. Hashtable: command line checking user /hashtable usage: ./hashtable -vflf textfile Hashtable: class code (60 points) *20: key_line subclass definition and implementation 20: hash_table use of key_line instead of template data 20: hash table::insert) and hash_table::find) updates Executable output examples Note: Blank lines have been inserted below for readability. Hashtable: command line checking user /hashtable usage: ./hashtable -vflf textfile

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Discuss the importance of workforce planning.

Answered: 1 week ago

Question

Differentiate between a mission statement and a vision statement.

Answered: 1 week ago