Skip to main content

Posts

Featured

Depth First Search

  What is Depth First Search(DFS) ?? Depth-first-search is an algorithm to search tree or graph data Structure. We use 4 parameter to implement the dfs algorithm..they are 1. Color 2. Parent(𝛑) 3. Distance(d) 4. Finishing Time (f) Algorithm DFS       DFS(G) For each vertex u ∊ V(G) Do color [u]⇠WHITE             π (u) ⇠ NILL time ⇠ 0 For each vertex u ∊ V(G)       do if color[u] = WHITE       then DFS_Visit(u) Algorithm DFS_VISIT      DFS_Visit(u) color[u] ⇠ GRAY time ⇠ time+1 d[u] ⇠ time For each vertex v ∊ ADJ[u] do if color[v]=WHITE         then π[v] ⇠ u               DFS_Visit(v) color[u] ⇠ BLACK f[u] ⇠ time ⇠ time + 1 Here is the example of DFS:--

Latest posts