Answered step by step
Verified Expert Solution
Link Copied!

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
image text in transcribed
image text in transcribed
You are expected to write a C++ console application which reads a text file that consists of logs of a web server. An example part of the log file is given below: After reading and processing is over, your program must list the "top 10 most visited web pages. Sample output : Filename1 \# of total visits Filename 2 \# of total visits Filename 3 \# of total visits Filename10 \# of total visits Total Elapsed Time : X seconds You should extract the filenames from each line. For example, the first line in the above log file contains the filename "index.html" and the second line contains the filename "1.gif". The application can be implemented with console facilities (you do not need advanced GUI elements). You are required to do the following tasks: Task1: You must implement a hash table as your main data structure. You should implement your own hash table, you cannot use a hash table implementation from a library. This implementation should be a proper c++ class. You should use this hash table for storing the filenames and the corresponding number of visits of that page (filename). There is no restriction on the choice of the hash function and collision resolution method. Task2: Use std::unordered_map data structure for storing the filenames and the corresponding number of visits. Task 3 : In order to compare the efficiency of your own hash table implementation and std::unordered_map, write a program which measures the total time it takes starting from reading access_log file until the end of printing the top 10 most visited pages. There is no need to ask user input. Note1: For finding the top 10 most visited pages try to find an efficient method. Hint: you can use the heap data structures. Note2: Other than the hash table implementation, you can use c++ standard library for your needs. You ave cepecied to wrise a C++ console application which reads a scat file that ecesists of logs of a whb server. An example part of the log file is spren below: Sample outpet : Flename1 Hof total visita Filename2 \# of toeal visis Filenames If of toeal visita Filenameto z of total visits Total Elspsed Time : X second Youskould extract the filenanes from each line. For ccample, the fout lies in the abose log file The application can be implemented with comole facilities goe do ass noed astanced GUT elements). You are requited to do the following tacks: Task1: You must implement a hash table as your main data structure. You should implement your own hash table, you cannot use a hash table implementation from a library. This implementation should be a proper C++ class. You should use this hash table for storing the filenames and the corresponding number of visits of that page (filename). There is no restriction on the choice of the hash function and collision resolution method. Task2: Use std::unordered_map data structure for storing the filenames and the corresponding number of visits. Task 3: In order to compare the efficiency of your own hash table implementation and std::unordered_map, write a program which measures the total time it takes starting from reading access_log file until the end of printing the top 10 most visited pages. There is no need to ask user input. Note1: For finding the top 10 most visited pages try to find an efficient method. Hint: you can use the heap data structures. Note2: Other than the hash table implementation, you can use C++ standard library for your needs

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_2

Step: 3

blur-text-image_3

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

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

Students also viewed these Databases questions

Question

List the benefits of depositary receipts to the investors.

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago

Question

Explain budgetary Control

Answered: 1 week ago

Question

Solve the integral:

Answered: 1 week ago

Question

What is meant by Non-programmed decision?

Answered: 1 week ago