thanks so much, cant thank you enough, i was struggeling with this problem for almost a whole day and now when you explained the whole algo it got so easy for me
14:25 I have doubt. Every time, it is not the case; each connected component is in proper order. Let 3 connected components are {0,1,8,9};{2,3,7};{4,5,6} for 10 vertex. So, if v becomes 9 after the first component, how will it process the next two components?
Mam the way u r teaching is really really amazing....mam keep doing the vedioes for us....thank u soo much for helping everyone like this....keep smiling mam🙂🙂🙂it tends u to look more beautiful..God bless u mam.I don't have any words to explain how amazing u are..
I think there are some issues with the code, but I can understand the idea ma'am was try to tell. Since DFS is used the vertices will be stored in the form of stack and they will enter one by one and when retraced the DFS fuction will exit and go back to connected component function, where count will be incremented and give you the number of componets . another thing to note here is that the 'u' ma'am has used here in order to acces the next element in the stack(the adjacent vertex) the index has to increment so that should be included.
🧐When DFS() calls return back v is never increased as v was passed as local variable. Still it shud work but u shud make flag as global or pass as reference
True...I also realised the same, v should be declared globally then or it must be static in DFS function...or we can do one thing We can declare some variable say x globally and with each call of DFS we can store this value of v in this x and obviously in connected components function we have to initiate loop with x=0;
Hello mam. Just a question? How will v directly be 4 after calling dfs for 1st component? When the control again passes to the for loop of connected function , wont it have a separate value of v (0 here )? as methods will maintain a separate copy of v? So wont it be initialised to 1? Then from v = 1 to 3 as the value of flag[v] = 1 it wont call dfs and for v = 4, as flag[v] = -1 , it will call dfs(4,-1) ?
when control passes to for loop again then it will go to v++ not v=0.... that is working of for loop..... for(initialization; condition; increment/decrement).. here firstly control go to initialization part then check the condition and if the condition is true then control will go within for loop and after executing all the statements written within for loop body the control will go to increment/decrement part...(not again to initialization part)..
@@JennyslecturesCSIT How can we access the variable v value which Is inside the DFS function directly from the for loop without returning it? From the video it seemed the for loop is going to iterate just 3 times...which should not be the case...I beleive it will iterate 9 times... but DFS function will be called just 3 times
@@JennyslecturesCSIT One more point is will the same code be working for vertices having any random integer value? Is the prerequisite is that the vertices has to start from 0 and gets incremented by 1
14:09 ma'am vo uske parent function m kaise update ho jayega. Vo sirf locally hi update hoga na. Ye bolo ki flag[v] ne 3 tak sabki value -1 kar di isliye vo skip skip karke 4 par aa jayga.
Mam what will happen if in dfs function there is if statement would be fail if one of adjacent flag value 1 then it will come out from the dfs function and increase count value by one but we know there is other adjacent that value is -1 it may be some error in code I think isn't mam?
'v' is local to the the for loop and and you are passing v by value not by reference so it make no how v value directly jump from 1 to 4. If you read this cmd plz rpy
Look we need to maintain adjacency matrix or list for that. For an adjacency matrix you need to find that row (which represents the node) and find if there's any available path from that node to any other node and if there's one we need to check whether that node is still unvisited. If both the conditions satisfy we return that number column stating that theres a path available from that row to that column.
hi mam nice video but i have a doubt since u have taken vertices number in ascending order algorithm is working but suppose if the vertices numbers are jumbled than will tis work
@@prematulasi6821 actually she explained wrong, if u use this same algo she wrote will be ok, the thing is she said v is updated as we backtrack, v=4 its not, cause we are not saving v=DFS(v,flag). we do not do it, so basically as backtracts, v=1-2-3-4(gets -1 enters loop)
@@prematulasi6821 definitely....but here i have just explained the algorithm not proper code. to convert it into code you will have to work hard as it is not as simple as this algorithm looks like.
What's going on ma'am in this DSA series i have been watching this from starting u didn't write code in any type of tree but in this u write and that is too in c++ what is this can anyone explain me..
Hey , mam I just saw your video and raised a doubt . My doubt is that you have taken vertices as 1,2,3... And taken a for loop where the v++ is increasing . If we take vertices as a,b,c... Then how the for loop will be operated ... And one more doubt , if the node traversal you shown 1-2-3-4 and increased v to 5 in the loop will be like 1-4-3-2 then what will be the vertices after the loop executed ones ?
I think your code is correct but you explained it slightly wrong! The v value is not getting incremented globally in the DFS function as you are explaining in the video. You explanation would fail when the connected components do not have the vertices in a serialized order. Please review you explanation and edit the video if possible.
thanks so much, cant thank you enough, i was struggeling with this problem for almost a whole day and now when you explained the whole algo it got so easy for me
Your videos are super cool. You are the one who makes things to understand easily.
Hi Madam, your explanation on the topic is crystal clear, thanks a lot for sharing your knowledge
U nailed it .
A big thumbs up for ur effort 👌🙏
Very simple and effective explanation. Thanks
Awesome work, your videos are so clear.
14:25 I have doubt. Every time, it is not the case; each connected component is in proper order. Let 3 connected components are {0,1,8,9};{2,3,7};{4,5,6} for 10 vertex. So, if v becomes 9 after the first component, how will it process the next two components?
I think that should be in increasing order
Your class been made me to score full marks
Mam please explain what about v's value how is this incrementing on both sides because you have called dfs by calling it by value but not by reference
send it by reference then by using pointer
Mam the way u r teaching is really really amazing....mam keep doing the vedioes for us....thank u soo much for helping everyone like this....keep smiling mam🙂🙂🙂it tends u to look more beautiful..God bless u mam.I don't have any words to explain how amazing u are..
Ma'am , your method works for undirected graphs,but we cant apply the same for directed ones.I think you should make a seperate video for it.
I think there are some issues with the code, but I can understand the idea ma'am was try to tell.
Since DFS is used the vertices will be stored in the form of stack and they will enter one by one and when retraced the DFS fuction will exit and go back to connected component function, where count will be incremented and give you the number of componets . another thing to note here is that the 'u' ma'am has used here in order to acces the next element in the stack(the adjacent vertex) the index has to increment so that should be included.
You got the error in this code bro congratulations 🤗🤗
Best explanation of conditional loop
Ma'am please continue DBMS , operating systems playlist ....
hit the nail on the head with the step by step process of explaining how the code works .Might i say, is that code snippet java or c++ ?
C++
Thank you a lot. Your video is worth 6 hours of mine reading documents
Mam make a video on strongly connected components
You start small
Mam ur all videos are awesome and very useful . Plz make videos on computer networking ..
🧐When DFS() calls return back v is never increased as v was passed as local variable. Still it shud work but u shud make flag as global or pass as reference
yes
Pls provide code
True...I also realised the same, v should be declared globally then or it must be static in DFS function...or we can do one thing
We can declare some variable say x globally and with each call of DFS we can store this value of v in this x
and obviously in connected components function we have to initiate loop with x=0;
very clear explanation didi. Also make videos on competitive programming
Good Explanations, love it but you should make another video foe directed graphs 😍
Mam u r explanation is super but we r not able to concentrate on topic because of u r beauty
If Jenna Fischer was indian
Hello mam. Just a question? How will v directly be 4 after calling dfs for 1st component?
When the control again passes to the for loop of connected function , wont it have a separate value of v (0 here )? as methods will maintain a separate copy of v? So wont it be initialised to 1?
Then from v = 1 to 3 as the value of flag[v] = 1 it wont call dfs and for v = 4, as flag[v] = -1 , it will call dfs(4,-1) ?
when control passes to for loop again then it will go to v++ not v=0.... that is working of for loop.....
for(initialization; condition; increment/decrement).. here firstly control go to initialization part then check the condition and if the condition is true then control will go within for loop and after executing all the statements written within for loop body the control will go to increment/decrement part...(not again to initialization part)..
@@JennyslecturesCSIT thank you mam
@@JennyslecturesCSIT mam but won't the value of v in the connected comments function be different to the one in DFS function?
@@JennyslecturesCSIT How can we access the variable v value which Is inside the DFS function directly from the for loop without returning it? From the video it seemed the for loop is going to iterate just 3 times...which should not be the case...I beleive it will iterate 9 times... but DFS function will be called just 3 times
@@JennyslecturesCSIT One more point is will the same code be working for vertices having any random integer value? Is the prerequisite is that the vertices has to start from 0 and gets incremented by 1
Lv u mam ❤️
Thank you so much. So helpful video.😊
In the first DFS recursive call when 0 is root then DFS(1,flag) and DFS(3,flag) will be in call stack and you only showed DFS(1,flag) :)
Thank You Ma'am
Loved it, helped me for one of my assignment, nicely explained
❤️❤️
14:09 ma'am vo uske parent function m kaise update ho jayega. Vo sirf locally hi update hoga na. Ye bolo ki flag[v] ne 3 tak sabki value -1 kar di isliye vo skip skip karke 4 par aa jayga.
Very nice video, have you coms across competitive programming
Yup
mam in flag[u] we know that it is the adjacent vertex of v graphically but how can we write in program because u is unknown not even declared?
But ma'am what if such graph given in which all nodes with each other then how to solve it
there is just one connected component that is called strongly connected component
Mam what will happen if in dfs function there is if statement would be fail if one of adjacent flag value 1 then it will come out from the dfs function and increase count value by one but we know there is other adjacent that value is -1 it may be some error in code I think isn't mam?
Nicely Explained, Thanks a lot . Can you please upload Tarjen's Algo for directed graph also. It is difficult to understand.
pls make a video for directed graph also on this topic
'v' is local to the the for loop and and you are passing v by value not by reference so it make no how v value directly jump from 1 to 4.
If you read this cmd plz rpy
Kumar Iyer's comment below. Read that dude
this algorithm will give strongly connected components ? i think it will give weakly connected components. Right ?
Ma'am, If I have doubts, do you have a separate Avenue( mail/ website) where I can doubts to you ?
What is the need to pass flag variable in DFS function
the global variable flag[u] = -1 at first? how does it take the adjacent vertices?
V is being passed by reference, that's why its getting updated in the calling function.
You are genious
strongly connected component and connected component is the same thing, right?
strongly connected means, each vertex has an edge to all other vertices.
No
could you use a for loop instead of a for each loop? and what would the for loop look like?
Can you explain about the biconnected component ma'am
EXCELLENT!!!
Thank you so much
Love you from pakistan
but how the value of v is increased after returning from the dfs ,flag must ble declare globally
Can someone please explain how I can find each adjacent node? Would an adjacency list be required?
Look we need to maintain adjacency matrix or list for that. For an adjacency matrix you need to find that row (which represents the node) and find if there's any available path from that node to any other node and if there's one we need to check whether that node is still unvisited. If both the conditions satisfy we return that number column stating that theres a path available from that row to that column.
Did you pass "flag" as an array or as a variable
Mam is it necessary to have the values in ascending order..inorder to have connecting components..?
Ya i think so
Will this work if connected components are not in order?
Will it work in directed graph!?
No, use tarzan's theorem
pls upload vedio on articulation points
Just awesome
Mam can you make video on strongly connected component
You declared variable V locally in for loop, it should be global.
@code fire still scope matters in pseudo code
very nice
what is the time complexty of this algorithm ?
Love you mam
Thank you
hi mam nice video but i have a doubt since u have taken vertices number in ascending order algorithm is working but suppose if the vertices numbers are jumbled than will tis work
mam iam waiting for ur r
eply
@@prematulasi6821 actually she explained wrong, if u use this same algo she wrote will be ok, the thing is she said v is updated as we backtrack, v=4 its not, cause we are not saving v=DFS(v,flag). we do not do it, so basically as backtracts, v=1-2-3-4(gets -1 enters loop)
@@prematulasi6821 definitely....but here i have just explained the algorithm not proper code. to convert it into code you will have to work hard as it is not as simple as this algorithm looks like.
@@Ballsbla Well said
@@JennyslecturesCSIT dhokha.... I shouldn't have seen this comment
What's going on ma'am in this DSA series i have been watching this from starting u didn't write code in any type of tree but in this u write and that is too in c++ what is this can anyone explain me..
madam make videos on gate questions on all topics
at 9.15 it is flag array, not flag = -1(small correction).
How to find strongly connected components of the following graph
@@anurajyendhe5981 I think ssc refers the directed graph
Thank
v apne dfs me update kar dia , apan ne pointer thodi pas kiya tha v one by one update hoga v=2,3 value par if ke andhar nahi jayega
but samaj a gay thank you mammm , love u mam
Aapk@ classes??
Hey , mam I just saw your video and raised a doubt . My doubt is that you have taken vertices as 1,2,3... And taken a for loop where the v++ is increasing . If we take vertices as a,b,c... Then how the for loop will be operated ...
And one more doubt , if the node traversal you shown 1-2-3-4 and increased v to 5 in the loop will be like 1-4-3-2 then what will be the vertices after the loop executed ones ?
G 253
look like an angel..
I think your code is correct but you explained it slightly wrong! The v value is not getting incremented globally in the DFS function as you are explaining in the video. You explanation would fail when the connected components do not have the vertices in a serialized order. Please review you explanation and edit the video if possible.
Kitna bhi focus krraha hu lecture pr nhi ho paraha bar bar tumhe dekhne lagta hu
❤️
Speed increase to 1.75x and thank me later :3
Thanks bro
👍👌
this code will fail for an input like [1,0], where 1 and 0 are nodes, connected by an edge. The answer will be 2 instead of 1.
Day 69
when you gonna smile :( :(
Ma'am totally connected component kisko khete hai
Love you Madam
You are too cute.
*sigh*
do you have any boyfriend?
Mam make a video on strongly connected components
Thank you