»
Breadth-first search: This technique begins at the root node, explores each of
the child nodes first, and only then moves down to the next level. It progresses
level by level until it finds a solution. The disadvantage of this algorithm is that
it must store every node in memory, which means that it uses a considerable
amount of memory for a large number of nodes. This technique can check for
duplicate nodes, which saves time, and it always comes up with a solution.
»
Depth-first search: This technique begins at the root node and explores a set
of connected child nodes until it reaches a leaf node. It progresses branch by
branch until it finds a solution. The disadvantage of this algorithm is that it can’t
check for duplicate nodes, which means that it might traverse the same node
paths more than once. In fact, this algorithm may not find a solution at all,
which means that you must define a cutoff point to keep the algorithm from
searching infinitely. An advantage of this approach is that it’s memory efficient.
Do'stlaringiz bilan baham: |