I am trying to get from TreeMap but it return null even the key exist. HashCode and eqauls is based on word only. Comparable is based on freqency.
public sta
This is what exactly happen in the TreeMpa.get() method,
while (p != null) { int cmp = k.compareTo(p.key); if (cmp < 0) p = p.left; else if (cmp > 0) p = p.right; else return p; }
TreeMpa use compareTo method to find the value. so it will loop through all the item till k.compareTo(p.key) return 0