Hashing quiz problem

Consider a hash table of size m = 10000, and the hash function h(K) = floor (m(KA mod 1)) for A = ( √(5) – 1)/2. The key 123456 is mapped to location .

answer: 41

kindly explain sir

Given hash function: h(K) = floor (m (K*A mod 1))
where A = ( √(5) – 1)/2

h(123456) = floor(10000 * (123456 * (√5 − 1) / 2) mod 1) 
          = floor(10000 * (76300.004115 mod 1)
          = floor(10000 * (.004115))
          = 41.15
          = 41 

So, 41 is correct answer

how are we performing this operation (76300.004115 mod 1)…as mod is invalid with float

this is question of hashing in general

% mod operator is defined for all numbers in math
but it is not defined for floats/double in c++ only

here we are doing calculation in general not c++ specific so here we consider
76300.004115 mod 1 = .004115

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.