SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot (20)

Ezmath
EzmathEzmath
Ezmath
 
Darkonoid
DarkonoidDarkonoid
Darkonoid
 
Python Tidbits
Python TidbitsPython Tidbits
Python Tidbits
 
ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Language
 
#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References
 
Compiling fµn language
Compiling fµn languageCompiling fµn language
Compiling fµn language
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 
C programming
C programmingC programming
C programming
 
Clang2018 class3
Clang2018 class3Clang2018 class3
Clang2018 class3
 
ODU ACM Python & Memento Presentation
ODU ACM Python & Memento PresentationODU ACM Python & Memento Presentation
ODU ACM Python & Memento Presentation
 
Card pack
Card packCard pack
Card pack
 
Py3k
Py3kPy3k
Py3k
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
Matlab code for Bisection Method
Matlab code for Bisection MethodMatlab code for Bisection Method
Matlab code for Bisection Method
 
Elixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII SorocabaElixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
 
Syed Ubaid Ali Jafri - Cryptography Techniques
Syed Ubaid Ali Jafri - Cryptography TechniquesSyed Ubaid Ali Jafri - Cryptography Techniques
Syed Ubaid Ali Jafri - Cryptography Techniques
 
Plsql
PlsqlPlsql
Plsql
 
Matlab Code for Bisection methode
Matlab Code for Bisection methode Matlab Code for Bisection methode
Matlab Code for Bisection methode
 

Algo for dfs

  • 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