Lecture 87: DFS Traversal in Graph || C++ Placement Series

preview_player
Показать описание
In this Video, we are going to learn about DFS Traversal in C++ and Questions

There is a lot to learn, Keep in mind “ Mnn bhot karega k chor yrr apne se nahi hoga ya maza nahi aara, Just ask 1 question “ Why I started ? “

Questions Links:

- DFS Traversal:

Do provide you feedback in the comments, we are going to make it best collectively.

Connect with me here:

Telegram Group Link: Love Babbar CODE HELP

Intro Sequence: We have bought all the required Licenses of the Audio, Video & Animation used.

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

DSA in c++ in Hindi and this type of explanation is no where available in youtube .... thanks for this course bhaiya so much needed for dsa preparation

subratamondal
Автор

Bhaiya..we are dependent on this series. Thank you so much for continuing

awesomepatt
Автор

Thank you har sum ko aisa batane ke lia ki kitna easy hai just the way you say makes it feels like haan ho to jaega !!!

VinniModi
Автор

haa bhiiyaa subkuch samaj aya ekdum badhiya tarike se..thanku bhaiyaa...love you..

prashantbirajdar
Автор

Bhaiya maine ek mahine se DSA shuruaat se padhna shuru kiya aapki series se abh confidence araha, Thankyou Bhaiya🙏

vaibhavgaur
Автор

// code for this lecture

void dfs(int node, unordered_map<int, bool> &visited, unordered_map<int, list<int>> &adj, vector<int> &component){
component.push_back(node);
visited[node]=true;
// har connected node k liye recursive call
for(auto i: adj[node]){
if(!visited[i]){
dfs(i, visited, adj, component);
}
}
}

vector<vector<int>> depthFirstSearch(int V, int E, vector<vector<int>> &edges)
{
// prepare adjlist
unordered_map<int, list<int>> adj;
for(int i=0;i<edges.size();i++){
int u = edges[i][0];
int v= edges[i][1];

adj[u].push_back(v);
adj[v].push_back(u);
}

vector<vector<int>> ans;
unordered_map<int, bool> visited;
//call all node DFS if not visited
for(int i=0; i<V;i++){
if(!visited[i]){
vector<int> component;
dfs(i, visited, adj, component);
ans.push_back(component);
}
}
return ans;
}

chandrasubhashinithakran
Автор

thank you so much bhaiya, I can proudly say that because of this course I got placed in Xebia. My package is 8lpa. Please continue making long videos bhaiya they have more conceptual knowledge and we are dependent on this course.

suyashverma
Автор

Great explanation ...
Consistency op..
Mja aa rha pdne mai 😎😎

dikshajain
Автор

Is to good course by Babbar bhaiya ❤❤❤ Love it

vishalgarna
Автор

maza aa gya bhaiya🙏🙏thanks for being consistent again

vijeas
Автор

Bas Ese hi babbar bhai ... bas web devlopment ka course aur chahiye

KCOYASH
Автор

Understood,
Attendance ++ & consistency++

anuragraut
Автор

why it has vector<vector<int>> data type if are returning a vector array so it should be vector<int> ans

_Deepak__Verma
Автор

okay, I dont know why everybody is not questioning this... How can we get the correct answer without using sets, just everyone dry run with list and then dry run with sets,

Test case:
5 6
0 3
0 2
1 2
1 0
4 2
4 1

See in this test case using lists we should get the ans :0 3 2 1 4
but it is showing 0 1 2 3 4

Is that already taken care in question before submitting the final answer?

priyanshkhunger
Автор

Bhaiya cn Or dbms ki bhivideos bnao... Please 🙏🙏🙏

nishudwivedi
Автор

After watching bfs, I was able to write dfs without even watching ur this vid 😊

MohammedAli-pbfg
Автор

Why first store the ans in component and then in final ans? Can we not directly store the result in ans vector like we did in BFS traversal?

hiddenmaster
Автор

Ahh it feels good to be consistent, keep the videos coming. Just a request, keep one long video of similar topics(eg bfs, DFS)

anshulsharma
Автор

Long length Videos == So much Content
Short length video == less content

Plzz bhaiya increase the length of videos 🙏 Aaapne shuru se mehnat karke itna achcha DSA course banaya he 💥 use wesaa hi rahne do 🙏🙌

Last ke kuch Topics ke karan Course ki quality Kam nhi hona chahiye 🙏🙏
#BeliveInBabbar #DSAbusted

unboxtheuniverse
Автор

Can anyone explain "component vector"? How is it behaving?
vector<int> component; // es line se to smjh hi nhi aa rha
I am not getting that how can we know that there is two components by code.

WizBoyYt