depth bredth first Flashcards
explain depth first(post order)
Depth first search goes as far down into the tree as possible before backtracking. The
algorithm uses a stack and goes to the left child node of the current node when it can. If
there is no left child then the algorithm goes to the right child.
If there are no child nodes, the algorithm visits the current node, outputting the value
explain bredth first
Starting from the left, breadth-first visits all children of the start node. The algorithm then
visits all nodes directly connected to each of those nodes in turn, continuing until every
node has been visited. Unlike depth first traversal (which uses a stack), breadth first uses
a queue.
what is the advantage of using depth first
Depth first requires less memory than breadth first
search (1). It is quicker if you are looking at deep
parts of the tree (1).
what is the disadvantage of using depth first
Depth first isn’t guaranteed to find the quickest
solution (1) and possibly may never find the
solution (1) if we don’t take precautions not to
revisit previously visited states (