In Java, write the SeperateChainingHashSTclass.
Insert the keys, "H A T R Q U Z I O V" in the order given intoan empty table of M=5 lists using separate chaining.
Use the hash function (11 * k) % M to turn thekth letter of the alphabet into a table index.
Given code:
public class SeperateChainingHashST
private int M=5;
private Node[]st = new Node[M];
private static class Node
{
private Object key;
private Object val;
private Node next;
}
private int hash(Key key)
{
return
}
public void add(Key key, Value val)
{
int i=hash(key);
for (Node x = st[i]; x!= null; x=x.next)
if(key.equals(x.key))
{
x.val=val;
return;
}
st[i]= new Node(key, val, st[i]);
}
public static void main(String[] args) {
}
}
没有找到相关结果