Question

For any given string x=x1x2x3⋯xm, a hash function is defined below as: (This is the entire...

For any given string x=x1x2x3⋯xm, a hash function is defined below as:

(This is the entire question, i cannot update it because this is it in its entirety)

h(x)=[c(x1)+c(x2)q+c(x3)q^2++c(xm)q^m-1 mod P

Here, both  and P are given small prime numbers, and denote the ASCII integer of the letter xi,1im. For any string y=y1y2yn, please show that if the hash value of the hash value yiyi+1⋯yi+k is known, then the hash value of yi+1yi+2⋯yi+k+1 can be computed in constant time. Please type answer if you can.

Homework Answers

Answer #1

Let Hash value for  yiyi+1⋯yi+k = h1(y)=[c(y1)+c(y1+2)q+c(y1+3)q^2++c(y1+k)q^m-1] mod P

Let time taken to calculate this hash value be t, and since we already have this value, the time taken to calculate it again will be O(1).

Now, Hash value for yiyi+1⋯yi+k.yi+k+1 = h2(y)=[c(y1)+c(y1+2)q+c(y1+3)q^2++c(y1+k)q^m-1 + c(y1+k+1)q^m] mod P

By the property of mod, this can be written as

h2(y) = [c(y1)+c(y1+2)q+c(y1+3)q^2++c(y1+k)q^m-1] mod P + c(y1+k+1)q^m mod P

h2(y)=h1(y)+c(y1+k+1)q^m mod P

Since, c(y1+k+1)q^m mod P is a simple expression, time taken to calculate is one unit.

We already have the value of h1(y), so no need to calculate it again.

now, h2(y) is a simple addition operation and takes one unit of time.

So total time taken = 1 unit + 1 unit = 2 units

2 units is constant time. Hence proved.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function...
Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function x mod 9, which of the following statements are true? (GATE CS 2004) i. 9679, and 1471 hash to the same value ii. 4199 and 6171 hash to the same value iii. All elements hash to the same value iv. Each element hashes to a different value (A) i only (B) ii only (C) i and ii only (D) iii or iv Show your...
For each of the following Python programs P and input strings I, give the output P(I),...
For each of the following Python programs P and input strings I, give the output P(I), using the formal definition of P(I) given, and employing any reasonable reference computer C: Definition of P(I), the output of a Python program. Let P be a Python program with respect to a reference computer system C. Suppose P has main function M, and let I be a string of ASCII characters that will be used as input to P. The output of P...
1. f is a probability density function for the random variable X defined on the given...
1. f is a probability density function for the random variable X defined on the given interval. Find the indicated probabilities. f(x) = 1/36(9 − x2);  [−3, 3] (a)    P(−1 ≤ X ≤ 1)(9 − x2);  [−3, 3] (b)    P(X ≤ 0) (c)    P(X > −1) (d)    P(X = 0) 2. Find the value of the constant k such that the function is a probability density function on the indicated interval. f(x) = kx2;  [0, 3] k=
Consider a two-person (1 and 2) two good (X and Y) exchange economy. The utility function...
Consider a two-person (1 and 2) two good (X and Y) exchange economy. The utility function of person i is given by ??=?????1−???Ui=xiaiyi1−ai where xi and yi denote respectively person i's the consumption amount of good X and good Y, i=1, 2.               Suppose the endowments and preference parameter of each person in the economy are given in following table:                     Endowment of X    Endowment of Y    Preference Parameter (ai ) Person 1          41                          32            ...
*******please don't copy and paste and don't use handwriting **** Q1: Using the below given ASCII...
*******please don't copy and paste and don't use handwriting **** Q1: Using the below given ASCII table (lowercase letters) convert the sentence “welcome to cci college” into binary values. a - 97 b - 98 c - 99 d - 100 e - 101 f - 102 g - 103 h - 104 i - 105 j - 106 k - 107 l - 108 m - 109 n - 110 o - 111 p - 112 q - 113...
A wave on a string has a wave function given by: y (x, t) = (0.300m)...
A wave on a string has a wave function given by: y (x, t) = (0.300m) sin [(4.35 m^-1 ) x + (1.63 s^-1 ) t] where t is expressed in seconds and x in meters. Determine: (10 points) a) the amplitude of the wave b) the frequency of the wave c) wavelength of the wave d) the speed of the wave
Probability density function of the continuous random variable X is given by f(x) = ( ce...
Probability density function of the continuous random variable X is given by f(x) = ( ce −1 8 x for x ≥ 0 0 elsewhere (a) Determine the value of the constant c. (b) Find P(X ≤ 36). (c) Determine k such that P(X > k) = e −2 .
The function y(x,t) = 0.3 sin( 2 π t -2 π x + π /4) represents...
The function y(x,t) = 0.3 sin( 2 π t -2 π x + π /4) represents the vertical position of an element of a taut string upon which a transverse wave travels. This function depends on the horizontal position along the string, x, and time, t. y and x are in units of meters and t is in units of seconds. Do not use symbols in any of your answers below. Only use integers or decimals. a. Determine the angular...
For each of the random quantities X,Y, and Z, defined below (a) Plot the probability mass...
For each of the random quantities X,Y, and Z, defined below (a) Plot the probability mass function PMS (in the discrete case) , or the probability density function PDF (in the continuous case) (b) Calculate and plot the cumulative distribution function CDF (c) Calculate the mean and variance, and the moment function m(n), and plot the latter. The random quantities are as follows: X is a discrete r.q. taking values k=0,1,2,3,... with probabilities p(1-p)^k, where p is a parameter with...
1. The cost function C and the price-demand function p are given. Assume that the value...
1. The cost function C and the price-demand function p are given. Assume that the value of C(x)  and p(x) are in dollars. Complete the following. C(x) = x^2/100 + 6x + 1000; p(x) = x/20+25 (a) Determine the revenue function R and the profit function P. R(x) =    P(x) = (b) Determine the marginal cost function MC and the marginal profit function MP. MC(x) =    MP(x) = 3. Determine the derivative for the given single-term function. When appropriate,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT