could you provide the full code of hashtable
Could you provide the full code of hashtable
I can send you the structure of the code, but not the full implementation. Try it yourself and let me know if you have any doubts in any function.
public class HashTable<K, V> {
private class HTPair {
K key;
V value;
public HTPair(K key, V value) {
this.key = key;
this.value = value;
}
public boolean equals(Object other) {
HTPair op = (HTPair) other;
return this.key.equals(op.key);
}
public String toString() {
return "{" + this.key + ";" + this.value + "}";
}
}
private LinkedList<HTPair>[] bucketArray;
private int size;
public static int Default_Capacity = 10;
public HashTable() {
this(Default_Capacity);
}
public HashTable(int capacity) {
this.bucketArray = (LinkedList<HTPair>[]) new LinkedList[capacity];
this.size = 0;
}
public void put(K key, V value) throws Exception {
}
private void rehash() throws Exception{
}
private int HashFunction(K key) {
}
public V get(K key) throws Exception{
}
public V remove(K key) throws Exception{
}
public void display() throws Exception {
}
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.