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 hk be the original hash function. The new index is computed as
hkihkcicimodn
Complete the function int quadraticprobeint hash, int i int n int c int c 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 c The first coefficient of the function.
int c The second coefficient of the function.
This function will also allow you to explore the effects of changing the coefficients c and c In most cases, you might use a default implementation where cc For this case, create a macro that defines a function call defaultprobehash i n to call the function quadraticprobehash i n
Add these functions to hashmaputils.ch The macro definition should be placed after the declaration in hashmaputils.h
Tasks
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
