You are viewing a single comment's thread. Return to all comments →
Java -Recursion
Node parent; void decode(String s, Node root) { StringBuilder sb = new StringBuilder(); parent = root; helper(s, 0, root, sb); System.out.println(sb.toString()); } void helper(String s, int index, Node root, StringBuilder sb){ if(root.left == null && root.right == null){ sb.append(root.data); root = parent; } if(index>= s.length()) return; if(s.charAt(index) =='0'){ helper(s, index+1, root.left, sb); }else{ helper(s, index+1, root.right, sb); } }
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 →
Java -Recursion