0
我正在尝试编写返回具有相同标签的所有节点的路径的JAVA代码。Java从根搜索具有相同标签的所有节点路径
在image specified in link。我应该得到以下O/P为标签Ç
A-> B
甲
作为输出。
我知道所有可能的标签。说标签的范围可以从A到J.
树的节点类:
class Node{
String label;
int count;
List<Node> children;
public int hashCode() {
return label.hashCode();
}
public boolean equals(Object obj) {
Node other = (Node)obj;
return other.label.equals(label);
}
}
我试图像
for(each label)
start from root
search for all possible label location
print path for each label location
但不能什么了解如何编写代码。请帮忙。
非常感谢。代码对我来说工作得很好。 我写简单printPath功能 私人无效printPath(列表路径) { 对(INT I = 0; I
2013-03-20 06:08:05