First of all I am so sorry if I am wrong, but I have confusions, if your community accepts this comment . Then I would like to point out that there are some mistakes in this video. First your graph 123456 in this video that is not matching with first loop. First loop is initialised with 0 and graph is starts from 1 means adjancey List not confirm. Second in second loop get(u) where is "u" sir I think src will be there.
Anuj Bhaiya- kya always graph 1 se start hoga like 1,2,3,4,5,6 ya random or agar random no honge toh upr jo apne btaya dist[neibor] = dist[cur] + 1; toh agar cur is 15 hai or next 43 hai toh + 1 ka kya logic hoga means use kya hoga?? Anser krna Anuj Bhiya wrna Confusion rh jayega
thanks for this video.. can you please make one on flipkart runway competition? It is exclusively for females and will give internship opportunities to the winners.. I am in my 2nd year and really want to try my best for this competition.. plz guide
Bhaiya when will video on data analytics will come as I am from computer science background I have tried my best from last 1.5 years and still not get coding 🥲 I think I have not interest in it kindly make a video on what is carrier option other than coding in CS and roadmap to get it
if we remove "vis[neighbour] == false" if statement from the while loop and add a condition that "if the new distance in lesser than previous distance only than we will add something in queue" by this can we find the shortest distance to reach from point a to point b
@Anuj For 2nd question finding the total connected component. Your using same fun BFS and passing last parameter as Vis wht is that? Also as per declaration of bfs fun it has 6 arguments and your passing 7 argument while finding the total component in the graph
The Best playlist for DSA on TH-cam. Thank you very much.
First of all I am so sorry if I am wrong, but I have confusions, if your community accepts this comment . Then I would like to point out that there are some mistakes in this video. First your graph 123456 in this video that is not matching with first loop.
First loop is initialised with 0 and graph is starts from 1 means adjancey List not confirm. Second in second loop get(u) where is "u" sir I think src will be there.
Sorry not "src" there will be "cur"
@@MithleshKumar-xq3qo right
Thank You So Much Bhayia for this awesome DSA playlist.. can you please complete it little quickly... totally dependent on this...
Sharma wo v Anuj "the best" . Thankyou bhaiya easily smjhane k liye.☺️
really helpful thanks a lot bhaiya
Very nice video.. maza aa gya bhaiya
you made graph so easy, awesome!!
Great Explanation !
Great explain... thanks bhaiya..
Anuj Bhaiya- kya always graph 1 se start hoga like 1,2,3,4,5,6 ya random or agar random no honge toh upr jo apne btaya dist[neibor] = dist[cur] + 1; toh agar cur is 15 hai or next 43 hai toh + 1 ka kya logic hoga means use kya hoga?? Anser krna Anuj Bhiya wrna Confusion rh jayega
Well explained.
Please make a 60day roadmap for DSA beginner who is working professional, a 60day roadmap to crack Microsoft linkedin level companies
Spectacular!
graph ke component more than 1 honge to dist[] and pred[] array harbar set honge na to code fail karega shayad??
Badhiya hai bhaiya
please also show code in c++ if possible..it will be more helpful..but awesome explanation..thanks!
Really helpful
Thank you so much
If we get the destination before going through each node in one component of graph then how can we find the no. Of components??
One question Anuj Bhaiya-- What is this 'u' in the code, not defined before
in place of 'u' you can replace with 'cur'
what is u in adj.get(u).get(i) ?
Tell me too if u know
@@aakashraj4142 in place of 'u' you can replace with 'cur'
bhayia it is so well explained please make a video on BFS , dfs , dls, uniform cost search, and greedy best-first search in python
thanks for this video.. can you please make one on flipkart runway competition? It is exclusively for females and will give internship opportunities to the winners.. I am in my 2nd year and really want to try my best for this competition.. plz guide
really helpful thank for your awesome work
as we are using predecesor array to track back the whole path , can we find multiple paths to reach from point "a" to "b" point b if they are present
bhaiya yha apne method bfs mnaya h and call dfs krre ho confusing hora h ye and wo boolean type h and ap int m return kra re ho
But sir. What is 'u'... Shouldn't it be adj.get(curr).get(i)
yes its 'cur'. Bhaiya replied in one of the comments
Thanks Bhai.
Bhaiya when will video on data analytics will come as I am from computer science background I have tried my best from last 1.5 years and still not get coding 🥲 I think I have not interest in it kindly make a video on what is carrier option other than coding in CS and roadmap to get it
What is u??.. Function return value bhoolen and storing ans in int!!??
Same doubt merko bhi hai bhai
if we remove "vis[neighbour] == false" if statement from the while loop and add a condition that "if the new distance in lesser than previous distance only than we will add something in queue" by this can we find the shortest distance to reach from point a to point b
whenever the pop out of like is appear i pause the video first and go to like, thanks for the pop out ;p
agar hme graph 1 2 and 1000 ka banana pde tb visited array size will be 1000 lagegi kya
Out of bound exception aaraha he bhaiya
i think ' u ' should be replace with ' cur '
why do we keep predecessor array ..
What is "u" variable?
same question
It was a typo. It's 'cur' actually instead of 'u'.
code is wrong and we need bfs traversal not only dist[]
In for loop what is 'u'
It's cur. Misspelt
@@AnujBhaiya i have written but showing out of bound
@@gamegem574 this is because I think the for loop need to be from 1 to v+1
Yup i have solved that thing
@Anuj For 2nd question finding the total connected component. Your using same fun BFS and passing last parameter as Vis wht is that? Also as per declaration of bfs fun it has 6 arguments and your passing 7 argument while finding the total component in the graph
u kidhar se aaya bhaiya
pls run the code at end
Nahi hoga run.. Wrong code he.. Errors he
1st
what is (u) in adj.get(u).size() at line 24 ------> 9:09
it is cur instead of u
Bahut fast padha rahe ho...confusion ho raha hai😢
can someone please clarify what is u here
@Anuj Bhaiya
so many mistajes found in ur code
Samjh me nhi aaya kuch bhi
bfs code:
public static boolean bfs(ArrayList adj, int src, int dest, int v, int pred[], int dist[]) {
LinkedList queue = new LinkedList();
boolean visited[] = new boolean[v + 1];
for (int i = 0; i < v; i++) {
visited[i] = false;
dist[i] = Integer.MAX_VALUE;
pred[i] = -1;
}
visited[src] = true;
dist[src] = 0;
queue.add(src);
while (!queue.isEmpty()) {
int cur = queue.remove();
for (int i = 0; i < adj.get(cur).size(); i++) {
int neighbour = adj.get(cur).get(i);
if (visited[neighbour] == false) {
visited[neighbour] = true;
dist[neighbour] = dist[cur] + 1;
pred[neighbour] = cur;
queue.add(neighbour);
if (neighbour == dest) {
System.out.println("Distance between source & destination: " + dist[dest]);
return true;
}
}
}
}
return false;
}
thnx bro this cleared my doubt :- from did tht "u" variable come from
For loop should have i
@@ruchikabhandari2768 error... index out of bounds exception
bhaiya int neighbour = adj.get(u).get(i) isme u kya hai? i think wo cur hoga
while fetching element from adjency list you kept adj.get(u).get(i), it should be adj.get(cur).get(i)