1 / 2

Depth-First Search Algorithm

Depth-First Search Algorithm. dfs ( v ) mark[v] :=1 print v for each (v, u)  Adj[v] if (mark[u] = 0) // not visited yet? dfs (u) Algorithm DEPTH_FIRST_SEARCH ( V, E ) for each v  V mark[v] := 0 // not visited yet for each v  V

Download Presentation

Depth-First Search Algorithm

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. Depth-First Search Algorithm dfs ( v ) mark[v] :=1 print v for each (v, u)  Adj[v] if (mark[u] = 0) // not visited yet? dfs (u) Algorithm DEPTH_FIRST_SEARCH ( V, E ) for each v  V mark[v] :=0 // not visited yet for each v  V if (mark[v]=0) then dfs (v)

  2. Breadth-First Search Algorithm bfs ( v , Q) mark[v]:=1 for each (v, u)  Adj[v] if (mark[u] != 1) // not visited yet? Q  Q + u Algorithm BREADTH_FIRST_SEARCH ( V, E ) ENQUEUE(Q ,{v0}) // an arbitrary node while Q != {} v:=DEQUEUE(Q) if (mark[v] != 1) print v bfs (v)// explore successors

More Related