Showing posts with label BFS. Show all posts
Showing posts with label BFS. Show all posts

Monday, 14 January 2013

Breath First Search

Breath First Search:-Breath First Search is a traversal technique comes in a Traverse Scheme of vertex's.This technique used in c,c++,java,C# etc.

BFS Algorithm:-

Now I discuss this algorithm in step wise. Step 1:-The Starting Vertex is A,initialise all vertex to ready state i.e. status=1.

Step 2:-Put A in Queue and change the status to waiting state i.e. status=2.

Step 3:-Repeat Step 4 & 5(until queue=empty).

Step 4:-Remove the top vertex and change the state to process state i.e. status=3.

Step 5:-(a)If status=1 then add vertex to rear and change the state into waiting  state.

(b)If status=2 then ignored.

(c)If status=3 then ignored.

Step 6:-Exit.


A    B,C,D
B    C,D,E,F
C    D,E,F
D    E,F
E    F,G
F    G
G    H

If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.