graph_search

graph_search - Begin While G has a non-visited node v do....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Graph Search Techniques 1- Tree search: Inorder (L N R) Preorder (N L R) Postorder (L N R). 2- Graph search: Given a graph G. Depth-first-search DFS (v) Begin Visited (v) =1; For every node w adjacent to v do If visited (w) = o then DFS (w); End if End for End. Complexity: O(max(n,e))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
3- Breadth first search: BFS (g). Q: queue ;
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Begin While G has a non-visited node v do. Visited (v) =1 ; Add queue (Q,v) ; While Q do. X = remove queue (Q) ; For every adjacent node w of X do. If visited (w)=o Then visited (w)=1 ; add queue (Q,w) ; Endif End for End while End while End. Complexity: O(max(n,e))...
View Full Document

Page1 / 2

graph_search - Begin While G has a non-visited node v do....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online