Implement 0, Addressing to store hashed data. Use as keys the last names in the
ID: 3697222 • Letter: I
Question
Implement 0, Addressing to store hashed data. Use as keys the last names in the patient.ret file in Project 2 chaining store hashed data. Use " keys the last.nain'esn:x=ct.'t file from course website. You can use implementation code given e Start by making the hash table or scatter table size 25. When collisions are detected your program should report this event and display a message that includes the index and key value information re the collision message. Keep a count of the total number of collisions and report that once the table has been completely populated by the keys from your patientect file. Include the capability to rehash the tables, for example you could implement this feature by allocating a new hash table twice the size of the old and insert the items into this new cable and then delete the old. Include a menu with the following capabilities, quitting the program, displaying the hash table (index and key values) and rehashing the table. Do not put main for part 1 and 2 in the same source code file, I should be able to compile and execute them separately. You are required to include a readme file re which you will explain your implementation specifically list your hash function and explain why you chose it and explain how your open addressing program handles collisions. Items to submit I, 1 and Part 2 should be put in different folders inside the zip file. Follow Project 0 guideline, and document any design or implementation choice madeExplanation / Answer
private static String hashString(String message, String algorithm)
throws HashGenerationException {
try {
MessageDigest digest = MessageDigest.getInstance(algorithm);
byte[] hashedBytes = digest.digest(message.getBytes("UTF-8"));
return convertByteArrayToHexString(hashedBytes);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
throw new HashGenerationException(
"Could not generate hash from String", ex);
}
}
private static String hashString(String message, String algorithm)
throws HashGenerationException {
try {
MessageDigest digest = MessageDigest.getInstance(algorithm);
byte[] hashedBytes = digest.digest(message.getBytes("UTF-8"));
return convertByteArrayToHexString(hashedBytes);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
throw new HashGenerationException(
"Could not generate hash from String", ex);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.