Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Help needed Breadth First Search & Depth First Search (http://www.go4expert.com/forums/help-breadth-search-depth-search-t27619/)

luckyali444 17Jan2012 18:28

Help needed Breadth First Search & Depth First Search
 
Hello there, i have a Metrics of 5X5 vertices. I want the implement BFS and DFS. First of all BFS.

here is my Metrics


v1 v2 v3 v4 v5

v1 0 1 0 0 1
v2 1 0 1 1 1
v3 0 1 0 1 0
v4 0 1 1 0 1
v5 1 1 0 1 0


Tell me please if i am wrong..

Breadth First Search
==============


Step 1: Add the Vertex V1 in a Queue and process all of its neighbors

Step 2: Once neighbors are processed, delete the Vertex V1 from Queue.

Step 3: Repeat the 1st and 2nd step until you dealt with all Vertices.




Depth First Search
=============


Please give me an idea about DFS so that i can go ahead and implement it by my own.



Thank you so much


All times are GMT +5.5. The time now is 04:58.