depth bredth first Flashcards

1
Q

explain depth first(post order)

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

explain bredth first

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is the advantage of using depth first

A

Depth first requires less memory than breadth first
search (1). It is quicker if you are looking at deep
parts of the tree (1).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is the disadvantage of using depth first

A

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 (

How well did you know this?
1
Not at all
2
3
4
5
Perfectly