これが私の関数です。ツリーのルートノードとツリー内にある文字をシードします。検索対象のアルファベットは正常に返されますが、要素へのパスは返されません。私は少し立ち往生しています
public Node traversingTree(Node root,String charToFind){
Node tempRoot = root;
if (root != null){
if (charToFind.equals(root.getAlphabet()))
{
//Another Point of consideration
System.out.print(root.getAlphabet());
System.out.println(": "+pathCodes);
pathCodes.clear();
return root;
}
Node result;
if ((result = traversingTree(root.leftChild, charToFind)) != null){
pathCodes.add("0");
return result;
}else
pathCodes.add("1");
return traversingTree(root.rightChild, charToFind);
}
}
pathCodes.clear();
return null;
}