What is the value of modulus of a negative value?

Thread Starter

zulfi100

Joined Jun 7, 2012
656
Hi,
I am trying to solve a problem of quadratic probing. I solved this earlier but now i cant figure it out. What is:
h(k) -4*4
where h(k) =9
9-16=-7
Now table size is 19 So
-7%19 =?

Also let table size is 7 & I want to hash 15:
15%7 = 1 +1*1 = collision(suppose)
15%7 = 1 + 2*2 = collision(suppose)
15%7=1 -2*2 = -3
what will we do now?
Please guide me.
Zulfi.
 

WBahn

Joined Mar 31, 2012
32,703
The usual definition of the modulus of 'a' mod 'n' where n > 0 is the value 'b' such that

a = n·k + b

and

0 ≤ b < n

So, based on that, what is -7 mod 19 ?
 
Top