You are viewing a single comment's thread. Return to all comments →
Simple Java Solutions :
void decode(String s, Node root) { String str = ""; Node head = root; for(int i = 0;i<s.length();i++) { if(s.charAt(i)=='0') { head = head.left; } if(s.charAt(i)=='1') { head = head.right; } str+=head.data; if(head.left==null && head.right==null) {
head = root; } } System.out.println(str.replace("\0", "")); }
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 →
Simple Java Solutions :