You are viewing a single comment's thread. Return to all comments →
String editStr(String s){ char [] cvtArray = s.toCharArray(); char [] newCh = new char[cvtArray.length -1]; for(int i=1; i<cvtArray.length; i++) newCh[i-1] = cvtArray[i]; return new String(newCh); } Node traverse(Node root){ if(root.left == null && root.right == null){ System.out.print(root.data); return null; } else return root; } void decode(String s, Node root) { Node temp = null; Node global = root; while(s.length() != 0){ if(s.charAt(0) == '0'){ temp = traverse(root.left); } else if(s.charAt(0) == '1'){ temp = traverse(root.right); } if(temp == null){ root = global; } else if(temp != null){ root = temp; } s = editStr(s); } }
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 →