Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rehashing requires recomputing the hash function for all items in the hash table. Since computing the hash function is expensive, suppose objects provide a hash

Rehashing requires recomputing the hash function for all items in the hash table. Since computing the hash function is expensive, suppose objects provide a hash member function of their own, and each object stores the result in an additional data member the first time the hash function is computed for it. Show how such a scheme would apply for the Employee class in Figure 5.8, and explain under what circumstances the remembered hash value remains valid in each Employee.

By "showing how such scheme would apply" it means update the program shown in Figure 5.8 with the new information/conditions given.

Figure 5.8:

image text in transcribed

#include #include using namespace std; // Example of an Employee class 4 Eclass Employee 10 public: const std::string &getName) const return name; 14 15 16 17 18 19 20 21 bool operator-(const Employee &rhs) const return getName() rns, getName(); bool operator!-(const Employee &rhs) const return (*thisrhs); 24 25 26 private: std::string name; double salary; int seniority; 28 29 30 31 32; // additional private members not shown template 35 Eclass hash 36 public: size t operatorO (const Employee &item) 38 39 static hash<:string> hf; return hf (item.getName()) 41 42 43

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

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago