You are viewing a single comment's thread. Return to all comments →
Almost the same as my code.
void decode(String encoding, Node root) { StringBuilder result = new StringBuilder(); Node curr = root; for (char ch: encoding.toCharArray()) { curr = ch == '0' ? curr.left : curr.right; if (curr.data != '\0') { result.append(curr.data); curr = root; } } System.out.println(result); }
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Huffman Decoding
You are viewing a single comment's thread. Return to all comments →
Almost the same as my code.