標準BFSの実装では(ウィキペディアの礼儀)のようなものです: Breadth-First-Search(Graph, root):
create empty set S
create empty queue Q
root.parent = NIL
Q.enqueue(root)
while Q is not empty:
ツリーを出力として受け取るlevel_order_travelという関数を定義する必要があります。リスト内のすべてのノードのリストをレベル順に出力します。 ここで、次のコードはこれを示しています def create_tree(node_list, index=1):
if index >= len(node_list) or node_list[index] is None:
私はパズルプログラムをコーディングしていました。 Javaプログラムをコンパイルすると成功しました。しかし、私がそれを実行すると、それは表示されます Solution to problem using breadth first :
Exception in thread "main" java.lang.NullPointerException
at SolvingProblem.isGoa