Question
Given the class HashTable with D buckets, write a function called FindMax , to find the record with maximum key in the Hash Table. To
Given the class HashTable with D buckets, write a function called FindMax , to find the record
with maximum key in the Hash Table. To accomplish this, you can assume that the class SortedChain
has a public function member also called FindMax that finds the record with maximum key
(is the last record of the chain) in a chain. The function FindMax of the class HashTable will call
the function FindMax of SortedChain for each of its buckets and will determine the record
with maximum key. You can assume that E is a class and Key( ) is a function of the class
that returns the key value:
class E {
public:
int key;
int data;
int KEY( ) {return key;}
}
The class SortedChain already contains a function FindMax that returns the record (or object E)
With maximum key , that is the last element of the chain;
template
class SortedChain {
public:
bool FindMax (E& e) const; // this function returns the element with maximum key
// return false if chain is empty, or first = 0; otherwise return true
}
The class HashTable has a function FindMax that uses FindMax of SortedChain for each of its buckets.
Write the function
template
class HashTable {
public
bool FindMax(E& e) const; // write a function to find the record (type E) with maximum
// key (return the record in E),
// since each of its buckets is a SortedChain, you must use
// Findmax of SortedChain. If the hash table is empty, return false
// otherwise return true
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started