Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i will write below the hashtable: #include #include #include using namespace std; class HashTable { public: HashTable(int size) : size_(size) { table_ = new vector(size);
i will write below the hashtable:
#include
#include
#include
using namespace std;
class HashTable {
public:
HashTable(int size) : size_(size) {
table_ = new vector(size);
for (int i = 0; i
table_[i].first = "";
table_[i].second = 0;
}
}
~HashTable() {
delete table_;
}
int size() {
return size_;
}
void insert(string key, int value) {
int hash = hash_function(key);
while (table_[hash].first != "" && table_[hash].first != key) {
hash = (hash + 1) % size_;
}
table_[hash].first = key;
table_[hash].second = value;
}
int get(string key) {
int hash = hash_function(key);
while (table_[hash].first != "" && table_[hash].first != key) {
hash = (hash + 1) % size_;
}
return table_[hash].second;
}
private:
int size_;
vector* table_;
};
now please continue solving task 2 that talks about the unordered_map make the code for it and make a program compare the time efficiency of the hashtable and the unordered_map and use the heap to get the top 10 visited pages
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