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)](https://content.bartleby.com/qna-images/question/9b63d5f0-a313-4df7-92fd-2acb696a8a17/addbe216-d580-4801-ad34-8b79cd4208cd/hxksjks_thumbnail.png)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps

Knowledge Booster
Similar questions
- Computer science questionarrow_forwardThe Java hash function for Strings computes a hash code based on a fixed maximum number of characters of the string. Given that Strings have no meaningful upper bound in length, describe how an effective, constant-time hashing algorithm can be constructed. (Hint: If you were to pick, say, eight characters to represent a string of length l, which would you choose?)arrow_forwardUse pythonarrow_forward
- Insert the following sequence of keys in the hash table.Keys = {4, 2, 1, 3, 5, 6, 8}Use linear probing technique for collision resolution: h(k, i) = [h(k) + i] mod mHash function, h(k) = 3k + 1Table size, M = 10 Draw the hash table, compute the index where the hashvalue will be inserted for each key, and show how you would use the technique when a collisionoccurs.arrow_forwardI am unaware of any distinction between Array lists and Hash tables.arrow_forwardWhat is the time complexity of delete function in the hash table using a doubly linked list?a) O(1)b) O(n)c) O(log n)d) O(n log n)arrow_forward
- Suppose you have a hash table of size N = 64, and you are using pseudo-random probing. The keys in your hash are 4-digit integers (0000 through 9999) and your hash function is h(k) = (the sum of the digits in k). Assume that the first 4 slots of your pseudo-random probing array contain: 5, 10, 60, 30 What are the first 4 values in the probe sequence (starting with the home position) for a record with key k=1948?arrow_forwardc++arrow_forwardThe following factors affect a hash table's Big-O performance in decreasing order:arrow_forward
- The Big O value of hashing is: O a. O(log N) O b. O(N) Oc O(N*Log N) O d. 0(1)arrow_forwardWhat is the average-case runtime required for a successful operation in a hash table using chaining where there are m buckets and n items in the hash table? Select one: a. O( n/m ) b. O(n) The answer depends on both n and m c. O( 1) d. O(m)arrow_forward2. Consider the Linear Hashing index. Linear Hashing | h1 000 001 010 011 ho ठ 00 01 10 11 Mod 8 (%68) Mod 4 (%4) 16* 21* 40* 37* 14* 18* 6* Primary Page 13* A. Show the resulting index after inserting the entry 9* C. Show the resulting index after inserting entry 7* 31* 19* 11* 23* B. Show the resulting index after inserting the entry 3* 30* D. Show the resulting index after inserting the entry 22* Overflow Pagearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios