Write a java program to implement the following algorithms for Open Addressing technique Hash Table data structure. (Use a simple array of integers to store integer key values only). HASH-INSERT(T,k) HASH-SEARCH(T, k) i = 0 repeat j = h(k, i) if T[j] == NIL T[j] = k return j else i = i + 1 until i == m 661 i = 0 repeat j = h (k, i) if T[j] == k return j i=i+1 until T[j] == NIL or i = m return NIL

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)
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS