We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a14e1e3 commit 01c3c83Copy full SHA for 01c3c83
src/main/java/com/thealgorithms/compression/LZ78.java
@@ -4,7 +4,7 @@
4
import java.util.HashMap;
5
import java.util.List;
6
import java.util.Map;
7
-
+import java.util.objects;
8
/**
9
* An implementation of the Lempel-Ziv 78 (LZ78) compression algorithm.
10
* <p>
@@ -97,12 +97,13 @@ public static List<Token> compress(String text) {
97
}
98
99
// Handle remaining phrase at end of input
100
- if (currentNode != root) {
+ if (!currentNode.equals(root)) {
101
compressedOutput.add(new Token(lastMatchedIndex, END_OF_STREAM));
102
103
104
return compressedOutput;
105
- }
+}
106
+
107
108
109
* Decompresses a list of LZ78 tokens back into the original string.
0 commit comments