Question: This is an example of adding linear hashing style, provide/ write an analysis/demonstration of the Big O time for the algorithm show all work give
This is an example of adding linear hashing style, provide/ write an analysis/demonstration of the Big O time for the algorithm show all work give big oh time/ cost of EACH LINE PLEASE!!!; public String retrieve(String key) {
int probe;
//variable to store probing location
int code = code(key);
//calculating the hash code
if (table[code] == null) return null;
//if the position is empty, immediately return failure...
else if (table[code].getKey().equals(key)) return table[code].getData();
//...but if it's a match, return the data straight away...
else { if (code == (table.length - 1) ) probe = 0; else probe = code + 1; } //...otherwise, probe to the next item, looping to zero if necessary
while ((probe != -1) && (probe != code)) { //keep probing until data is found or entire table has been visited
if (table[probe] == null) return null;
//if the probed element is completely empty, return failure
else if (table[probe].getKey().equals(key)) { return table[probe].getData(); } //if the probed element is a match, return the data...
else { if (probe == (table.length - 1) ) probe = 0; else probe++; } } //...otherwise, keep probing for the next item, looping back to zero if necessary
return null; }
//if nothing has been returned by now, data is not present
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
