Presentation is loading. Please wait.

Presentation is loading. Please wait.

EMIS 8374 Search Algorithms: DFS Updated 12 February 2004

Similar presentations


Presentation on theme: "EMIS 8374 Search Algorithms: DFS Updated 12 February 2004"— Presentation transcript:

1 EMIS 8374 Search Algorithms: DFS Updated 12 February 2004

2 Depth-First Search Always pick the last (most recently added) node in the LIST Pick marked nodes in a last-in, first-out order (LIFO) Breadth-First Search uses a FIFO order Makes a “deep” probe, creating as long a path as possible Backs up when it can’t mark a new node

3 Depth-First Search 1 2 4 3 5 6

4 Depth-First Search 5 2 1 2 4 3 5 6 4 6 3 List = {} List = {1}

5 Depth-First Search Tree
5 2 2 4 1 6 1 4 3 5 6 3

6 Properties of a DFS Tree
If node j is a descendant of node i, then order(j) > order(i) All descendants of any node are ordered consecutively in sequence. That is, suppose that order[i]= p and i has q descendants. Then, any node j such p+1 ≤ order[j] ≤ p+q is a descendant of node i.

7 A Depth-First Search Tree
5 1 2 4 3 5 6 3 Order visited =

8 Not A Depth-First Search Tree
4 2 2 4 1 6 1 6 3 5 3 5 Order visited =


Download ppt "EMIS 8374 Search Algorithms: DFS Updated 12 February 2004"

Similar presentations


Ads by Google