Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help. Dont understand . The code has following 4 functions: 1 ) div _ hash ( int key, int M ) : divides key

Please help. Dont understand .The code has following 4 functions:
1) div_hash(int key, int M): divides key k with M size of hash table and use remainder of it, returns hash value
h(K)= k mod M
k =12345
M =95
h(12345)=12345 mod 95
=90
2) mid_sqr_hash(int key, int M): it has 2 steps:
1) Square the key k, which is k*k.
2) Take digits from square of key by dividing it by M and further mode by M, return hash value
h(K)= h(k x k)
k =60
M =100
k x k =60 x 60
=3600
h(60)=60//100%100
The hash value obtained is 60
3) double_hash (int key, int M):
h1(key)= key%M
h2(key)=1+(key%13)
rehash(key)= h1(key)+i*h2(key) i starts from 1 repeat untill you get hashvalue which is palindrome number
example : key =12345
M =1000
h1(12345)=345
h2(12345)=1+(12345%13)=1+8=9
i =1 rehash =345+1*9=354354 is not palindrome
i=2 rehash =345+18=363 is palindrome stop
if i>5 and rehash value is not palindrome then make reverse of rehash as hash value.
return hash value
4) mult_hash(int key, int A):
Perform following steps:
1) Choose a value A from 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions