1. ALGO FOR DFS
Suppose you have a matrix,
A B C
A 0 1 0
B 0 0 1
C 1 0 0
For i= 1 to 3
For j=1 to 3
//Initially, ur all nodes will be un-visited,So
DFS [j] == -1
If A[i][j] == 0 /// for ur adjacency matrix
Dfs[j] == count +1
// at the end return
DFS(j, count)
LEVEL ORDER TRAVERSAL
I hope this link will help you all :)
http://www.sourcetricks.com/2011/05/c-level-order-traversal-of-b-tree.
html#.VIhJb39NM67