1 / 8

EMIS 8374 Search Algorithms: DFS Updated 12 February 2004

EMIS 8374 Search Algorithms: DFS Updated 12 February 2004. 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

pilis
Download Presentation

EMIS 8374 Search Algorithms: DFS Updated 12 February 2004

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EMIS 8374Search Algorithms: DFSUpdated 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. 2 4 1 6 1 3 5 Depth-First Search

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

  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. 2 2 4 1 6 1 4 3 5 6 A Depth-First Search Tree 5 3 Order visited = 1 2 5 6 4 3

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

More Related