// open hash table of students, second version, polymorphic, and oop. import java.util.*; // for ArrayList abstract class hashtable { // HT is an array of linked lists! protected ArrayList[] HT; // can't be ArrayList unfortunately // no constructor in abstract class // The hash function given a key: public abstract int hash(KeyTy S); // The following function extracts the Key from the Value: public abstract KeyTy getkey(ValueTy v); // inserting a new student object into the table: public void insert(ValueTy S) { int h = hash(getkey(S)); HT[h].add(S); // add student to array list at hashed position } // searching for a student by key public ValueTy search(KeyTy key) { ArrayList L = HT[ hash(key) ]; ValueTy answer = null; for(int i=0;i L = HT[ hash(key) ]; ValueTy answer = null; for(int i=0;i R : HT) for(int i=0;i { public int hash(Integer id) { return id % HT.length; } public Integer getkey(student v) { return v.id; } public studenthash(int max) { ArrayList[] HTw = new ArrayList[max]; HT = (ArrayList[])HTw; for(int i=0;i(); } }// studenthash concrete class public class polyhash { /* uncomment main for testing: */ public static void main(String[] args) { studenthash SH = new studenthash(100); SH.insert(new student("mary",700234123,3.5,1)); SH.insert(new student("larz",700555123,2.0,3)); SH.insert(new student("narx",700444223,2.8,0)); for(int i=0;i<10;i++) SH.insert(new student()); // random student student l = SH.search(700555123); SH.delete(700234123); student m = SH.search(700234123); System.out.println(l); System.out.println(m); SH.printall(); } }