27-09-2016, 12:06 PM
1456312500-dfsbfs.ppt (Size: 224.5 KB / Downloads: 3)
Depth-first searching
A depth-first search (DFS) explores a path all the way to a leaf before backtracking and exploring another path
For example, after searching A, then B, then D, the search backtracks and tries another path from B
Node are explored in the order A B D E H L M N I O P C F G J K Q
N will be found before J
Breadth-first searching
A breadth-first search (BFS) explores nodes nearest the root before exploring nodes further away
For example, after searching A, then B, then C, the search proceeds with D, E, F, G
Node are explored in the order A B C D E F G H I J K L M N O P Q
J will be found before N