Bartleby Related Questions Icon

Related questions

Question
Task - 1:
Write a java program to implement the following algorithms for Open Addressing techniques for
Hash Table data structure. (Use a simple array of integers to store integer key values only).
HASH-SEARCH(T, k)
HASH-INSERT (T, k)
i = 0
repeat
j = h (k, i)
if T[j] == NIL
T[j] = k
return j
else i = i + 1
●
i = 0
repeat
until i == m
error “hash table overflow"
For both algorithms, to compute the index j, write the following methods:
getLinear ProbIndex (key, i)
getQuadraticProbIndex
● get DoubleHash (key, i)
(key, i)
j = h (k, i)
if T[j] == k
return j
i = i + 1
until T[j] == NIL or i = m
return NIL
Linear Probing index is computed using following hash function:
h(k, i) = (h₁(k) + i) mod m
h₁(k)= k mod m
Quadratic probing index is computed using following hash function:
h(k, i) = (h₁(k) + i²) mod m
h₁(k)= k mod m
Double hashing index is computed using following hash function:
h(k, i) = (h₁(k) + i h₂(k)) mod m
h₁(k)= k mod m
h₂(k) = 1 + (k mod m - 1)
expand button
Transcribed Image Text:Task - 1: Write a java program to implement the following algorithms for Open Addressing techniques for Hash Table data structure. (Use a simple array of integers to store integer key values only). HASH-SEARCH(T, k) HASH-INSERT (T, k) i = 0 repeat j = h (k, i) if T[j] == NIL T[j] = k return j else i = i + 1 ● i = 0 repeat until i == m error “hash table overflow" For both algorithms, to compute the index j, write the following methods: getLinear ProbIndex (key, i) getQuadraticProbIndex ● get DoubleHash (key, i) (key, i) j = h (k, i) if T[j] == k return j i = i + 1 until T[j] == NIL or i = m return NIL Linear Probing index is computed using following hash function: h(k, i) = (h₁(k) + i) mod m h₁(k)= k mod m Quadratic probing index is computed using following hash function: h(k, i) = (h₁(k) + i²) mod m h₁(k)= k mod m Double hashing index is computed using following hash function: h(k, i) = (h₁(k) + i h₂(k)) mod m h₁(k)= k mod m h₂(k) = 1 + (k mod m - 1)
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS