Depth first search | DFS | Depth first traversal

preview_player
Показать описание
This video explains a very important concept for graph which is depth first search also known as depth first traversal,i.e., DFS or DFT. The concept is explained for both the UNDIRECTED as well as DIRECTED graph in easiest way possible to help you grasp concepts easily. The code is explained at last after the theoretical concepts and the CODE LINK is present below. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)

Рекомендации по теме
Комментарии
Автор

My TECHnical knowledge is getting over DOSEd by watching your channel. Thank you Man!

ravigadadi
Автор

I must say, it is a perfect resource to learn DFS.
Keep explaining code also for each and every problem.
Thanks for your efforts.
Eagerly waiting to see grow your channel to 6 digit family.

patilsoham
Автор

You are amazing, your channels needs a boom.
Unlike other, your method of explaining is the best.

shivamchauhan
Автор

This is the simplest explanation and implementation of dfs! Great work

shrirampareek
Автор

It took me some time to implement this in C, I nearly started pulling my hair out. Without your tutorial, I would have been completely lost, such an elegant solution.

dipperyawn
Автор

Everyone can learn recursion and DFS from you 😄 great work brother 👏

gnanajeyam
Автор

At 11:29 in undirected graph what happen if we choose C vertex as starting vertex that has no path to reach other vertices ??

eshankaur
Автор

Please try to make more videos, Your explanation is crisp and very easy to understand.

soumensinha
Автор

the best explanation ive ever seen, thanks man

Randomguy-zvtv
Автор

Awesome Work . I have seen many of your video. I am a beginner but everything is very well explained. Good work.

kumarpriyansh
Автор

Please also showcase the output in your videos for better understanding and visual result of the code.

vidishasharma
Автор

I can see now how you are so genius, You are Itachi (11:36) 🤩😂😂😂
btw very helpful video, Thank you sir.

sugat
Автор

this was excellent...can you do one dfs by iterative method too?

chandanbanerjee
Автор

why g[s][i] is called in dfs function as it 'll give a vertex value and not index...
and if i consider it vertex value than y you passed 0 intially because maybe 0 will be not present

jiteshkumar
Автор

what is Morris Transversal? There is no video available in your playlist. can you explain me a little bit.

kuchalaggyan
Автор

Hi,

Did I miss anything or the example is not accurate to justify the use of stack. If on backtracking we are just visiting vertex, then why keep them in stack at all? I got confused in this and I think may be the example here is not making use of stack but there could be case where stack can be used when all neighbouring vertex are not visited yet.

ManpreetSingh-kiyh
Автор

Bro Its very useful and informational
Now I got confidence that, I can crack any DSA coding interview

But. I need help in system design
Do u have any reference for it

Venkat.devisetti
Автор

what if we are at a vertex which has only incoming edges?

ManpreetSingh-kiyh
Автор

Hi..could you please help me with the explaintion of time complexity of DFS approach explained in the video

yashwanthsai
Автор

Java code is below

import java.util.Iterator;
import java.util.LinkedList;

public class Graph {

int nodes;
LinkedList edges[] ;
boolean visited[];

public Graph(int nodes) {
this.nodes = nodes;
edges = new LinkedList[nodes];
visited = new boolean[nodes];

for(int i=0;i<nodes;i++) {
edges[i] = new LinkedList<Integer>();
}
}


public void addEdge(int n, int e)
{
edges[n].add(e);
}

public static void main(String[] args) {

Graph g = new Graph(4);

g.addEdge(0, 1);
g.addEdge(0, 2);
g.addEdge(1, 2);
g.addEdge(2, 0);
g.addEdge(2, 3);
g.addEdge(3, 3);


g.DFS(2);
}


private void DFS(int edge) {

visited[edge]=true;
System.out.print(edge);
Iterator<Integer> i = edges[edge].listIterator();
while (i.hasNext())
{
int n = i.next();
if (!visited[n])
DFS(n);
}

}






}

Venkat.devisetti