List<Tree<T>> unvisited = node.getChildren();
文件系统:
while (!unvisited.isEmpty()) {
Tree<T> node = unvisited.remove(0);
//search node
unvisited.addAll(0, node.getChildren());
}
BFS:
while (!unvisited.isEmpty()) {
Tree<T> node = unvisited.remove(0);
//search node
unvisited.addAll(node.getChildren());
}
这些实现是否过于简单而令人难以置信?想知道我是否遗漏了什么?