Question: C++ Write a function that will compute the Bloom filter hash function defined above (h p) for an input string, an input value of p,
C++
Write a function that will compute the Bloom filter hash function defined above (hp) for an input string, an input value of p, and an input value of $m$. Your function must take three parameters: a string s, a integer value for p, and an integer filter size m. It must return an integer that is the value of the hash function hp(s).
The main function of your program should get the three inputs from the user, then call the hash function and print its value. The inputs are (1) a line of text that is the input string to be hashed, (2) the p value for the hash function, and (3) the size of the filter, m. Your program must have a second function to do the hash calculation. (The hash calculation may not be in main.)
Sample Program Run
Please enter a string: hi Please enter a value for p: 31 Please enter a filter size m: 100 h_31("hi") = 59 The calculation of h_p("hi") is given as follows:
s = "hi" (ASCII values: h=104, i=105) p = 31 m = 100 h_31("hi") = (31^0 * 104 + 31^1 * 105) % 100 = 3359 % 100 = 59 Things to remember:
As always, include your name as a comment at the top of the code, and make sure to submit source code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
