25-2 中序遍历( 四 )

< paraString.length(); i++) {if (paraString.charAt(i) == '0') {tempNode = tempNode.leftChild;System.out.println(tempNode);} else {tempNode = tempNode.rightChild;System.out.println(tempNode);} // Of ifif (tempNode.leftChild == null) {System.out.println("Decode one: " + tempNode);// Decode one char.resultCodeString += tempNode.character;// Return to the root.tempNode = getRoot();} // Of if} // Of for ireturn resultCodeString;} // Of decoding/********************** The entrance of the program.* * @param args*Not used now.********************/public static void main(String[] args) {Huffman tempHuffman = new Huffman("D:/desktop/123.txt");tempHuffman.constructAlphabet();tempHuffman.constrcuTree();HuffmanNode tempRoot = tempHuffman.getRoot();System.out.println("The root is: " + tempRoot);System.out.println("Preorder visit: ");tempHuffman.preOrderVisit(tempHuffman.getRoot());tempHuffman.generateCodes();String tempCoded = tempHuffman.coding("abcdb");System.out.println("Coded: " + tempCoded);String tempDecoded = tempHuffman.decoding(tempCoded);System.out.println("Decoded: " + tempDecoded);} // Of main} // Of class Huffman
截图: