How can implement a perfect hashed data structure using the four basic operations? Could I do something like this or do I need to break up my code into two different classes and then test the methods from another class's main method?
public class PerfectHashed{
int ticketNumber; // keyfield
String PurchaserName;
input(){
// key values ranges between 2000 to 100, 000
System.out.print("Please enter a ticket number between 2000 to 100,000: " );
// to hold there answer.
number= nextInt();
}
// Then would need the four basic operations in my application:
// the insert direct hashed algorithm
pseudoKey = preProcessing(targetKey);
ip = pseudoKey; // direct hashing function
// insert the new node
data[ip]= newNode.deepCopy();
// the fetch algorithm
// access the primary storage area
pseudoKey = preprocessing(targetKey);
ip = pseudoKey; // direct hashing function
if(null[ip] = = null)
{ return null; }
else{return data[ip].deepCopy();
}
// the delete direct hashed algorithm
// access the primary storage area
pseudoKey = preprocessing(targetKey);
ip = pseudoKey; // direct hashing function
if(null[ip] = = null)
{ return false; }
else
{ data[ip]=null;
return true; }
}
// the update direct hashed algorithm
if(delete(targetKey) == false)
return false;
else
{
insert(newNode) return true;
}