Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago