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
hi 31 100
Your output correctly contains
h_31("hi") = 59
Input
happy_days 97 1024
Your output does not contain
h_97("happy_days") = 242
Input
abcdefghijklmnopqrstuvwxyz01234567879 103 200
Your output does not contain
h_103("abcdefghijklmnopqrstuvwxyz01234567879") = 41
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started