Question: When working with larger codebases, it is easy to get overwhelmed. Any obstacles encountered, no matter how small, can seem insurmountable. Our first task is

When working with larger codebases, it is easy to get overwhelmed. Any obstacles encountered, no matter how small, can seem insurmountable. Our first task is to modify the Makefile for our project. This will make it simple to compile our project and test the different components we will be adding.
Feel free to use the example we did in class or the cookbook from makefiletutorial.com to get started.
Tasks
Modify the Makefile with the following targets:
release: Builds the full project normally. The executable should be placed in a build directory.debug: Builds the project with the flags -g -Wall.
Verify that your Makefile works by building the project and running it (requires all tasks complete).
Collision Resolution using Quadratic Probing
One flaw of linear probing for collision resolution is that samples tend to cluster together in different parts of the map. An alternative open addressing scheme that does not suffer from clustering is quadratic probing.
Quadratic probing computes a new index based on the result of a hash function and quadratic function. Let h(k) be the original hash function. The new index is computed as
h(k,i)=(h(k)+c1i+c2i2)modn.
Complete the function int quadratic_probe(int hash, int i, int n, int c1, int c2) that computes the function above. The input arguments are:
int hash - The original hash value computed by the hash function.
int i - The parameter i as described above.
int n - The size of the hash map.
int c1- The first coefficient of the function.
int c2- The second coefficient of the function.
This function will also allow you to explore the effects of changing the coefficients c1 and c2. In most cases, you might use a default implementation where c1=c2=1. For this case, create a macro that defines a function call default_probe(hash, i, n) to call the function quadratic_probe(hash, i, n,1,1).
Add these functions to hash_map_utils.(c|h). The macro definition should be placed after the declaration in hash_map_utils.h.
Tasks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!