1. Homepage
  2. Programming
  3. CS3334 Data Structures - Assignment: Hash Table

CS3334 Data Structures - Assignment: Hash Table

Contact Us On WeChat
Hong KongCity University of Hong KongCS3334Hash TableC++

Assignment: Hash Table

CS3334 Teaching Team November 9, 2022 CourseNana.COM

1 Overview

You are required to maintain a hash table T which supports the following operations: Insert(x): Insert the key x to T ; Delete(x): Remove the key x from T if exists; Search(x): Determine if x is contained in T , and if so, return a pointer to x. It is not allowed to use any C++ STL containers (e.g., std::vector, std::set, std::map). CourseNana.COM

2 Detailed Requirements

In this project, you are asked to implement and compare different types of hash algorithms to achieve the operations listed above. In particular, it should be organized as follows. CourseNana.COM

  1. Hash function. In this part, you need to try and implement at most 4 different hash functions for numerical data, such as CourseNana.COM

    • Division method: h(x) = x mod M , where x is the key value, M is the size of the hash table;
    • Mid-square method: h(x) = x2 mod M ;
    • Multiplication method: h(x) = bM (xA mod 1c), where A is a constant real number, mod denotes extraction of the fractional part of xA; P
    • Digital folding method: h(x) = xi , where xi is the i-th digit of x. You may also try other hash functions, or propose your own designs. Hash functions for other data types (e.g., strings) are appreciated but not necessary.
  2. Collision resolution. In this part, you need to try and implement at most 4 different collision resolutions, such as CourseNana.COM

    • Separate chaining. In this approach, the collided items are chained together to each entry of the hash table. You may use different data structures to chain those collided items, including – linked list; – self-balancing binary search tree; – another hash table;
    • Open addressing. In this approach, each entry of the hash table stores a key x rather than a pointer to the chained items. Probing is a common approach to achieve this, including – linear probing; – quadratic probing; – double hashing.

In the above probing methods, we assume to adjust the target entry of later arrived items, i.e., first-come entries will not be moved to other entries. However, we may also move those first-come items to other positions and place a newly collided item into the current entry, examples including – Cuckoo hash; – Robin Hood hash. CourseNana.COM

Note that you are NOT required to try and implement all examples mentioned above. But you need to explicitly explain what types of hash functions and collision resolutions you choose rather than simply putting the terminology there. It is recommended to discuss the pros and cons, the time complexity for three operations (average time complexity, worst-case time complexity), and other valuable things (e.g., in what kind of scenarios, we should use what kind of methods). Note that formal time complexity analysis for collusion resolutions is unnecessary since it requires in-depth mathematical understanding. But some intuitive or informal discussion would be appreciated. The challenging part would be designing some input data that trigger the worst-case running time of the hash algorithms. CourseNana.COM

  1. Experimental Evaluations. CourseNana.COM

    • In this project, you need to design and generate the test data for your hash algorithm. The generator programs should be written in C++, and the data you generated should meet the constraints in the problem description. A sample generator is available on canvas. In particular, you may generate input data randomly or according to some customized rules.
    • You are required to evaluate and compare the differences in efficiency among different hash algorithms. Figures that intuitively show how the scale of the input data affects the running time, how different hash functions or the function parameters affect the collision rate, and empirical comparison among different methods are appreciated. Since theoretical analysis is too sophisticated for us, experiments would be of great importance. The compiling command for compiling your programs should be clearly stated in the report, e.g., g++ sampleGenerator.cpp -o exec file. Some available compiling options are -std=c++11, -lm, -O2.
  2. Conclusions. You may start with further research about the hash algorithms by reading some references. CourseNana.COM

Get Expert Help On This Assignment

Scan above qrcode with Wechat

Hong Kong代写,City University of Hong Kong代写,CS3334代写,Hash Table代写,C++代写,Hong Kong代编,City University of Hong Kong代编,CS3334代编,Hash Table代编,C++代编,Hong Kong代考,City University of Hong Kong代考,CS3334代考,Hash Table代考,C++代考,Hong Konghelp,City University of Hong Konghelp,CS3334help,Hash Tablehelp,C++help,Hong Kong作业代写,City University of Hong Kong作业代写,CS3334作业代写,Hash Table作业代写,C++作业代写,Hong Kong编程代写,City University of Hong Kong编程代写,CS3334编程代写,Hash Table编程代写,C++编程代写,Hong Kongprogramming help,City University of Hong Kongprogramming help,CS3334programming help,Hash Tableprogramming help,C++programming help,Hong Kongassignment help,City University of Hong Kongassignment help,CS3334assignment help,Hash Tableassignment help,C++assignment help,Hong Kongsolution,City University of Hong Kongsolution,CS3334solution,Hash Tablesolution,C++solution,