diff --git a/Java/TriesWithFrequencies/src/TrieFunctions.java b/Java/TriesWithFrequencies/src/TrieFunctions.java index 365b1cf4..160ddf89 100644 --- a/Java/TriesWithFrequencies/src/TrieFunctions.java +++ b/Java/TriesWithFrequencies/src/TrieFunctions.java @@ -539,8 +539,10 @@ protected static Trie shrinkRec(Trie tr, String delimiter, double threshold, int List arr = new ArrayList(tr.getChildren().values()); boolean shrinkQ = false; - if (threshold < 0) { - shrinkQ = tr.getValue().equals( arr.get(0).getValue() ); + if (threshold < 0 && tr.getValue() >= 1.0 && arr.get(0).getValue() >= 1.0 ) { + shrinkQ = tr.getValue().equals(arr.get(0).getValue()); + } else if (threshold < 0 ) { + shrinkQ = arr.get(0).getValue() == 1.0 ; } else { shrinkQ = arr.get(0).getValue() >= threshold; }