10 Graph Theory:: Bellman Ford's Algorithm with CSES 10 High Score (1673)

  Рет қаралды 12,142

Dardev

Dardev

Күн бұрын

Пікірлер: 74
@sambhavsinha8844
@sambhavsinha8844 Жыл бұрын
Your teaching approach reminds me of one of my previous teachers, who was unparalleled (atleast for me) ... Thank you sir for such content
@leviackerman9882
@leviackerman9882 4 жыл бұрын
I couldn't understand anywhere why it needs to run at most n-1 times And you made it super easy with that example Thank you so much ❤️
@rahulsawant2093
@rahulsawant2093 Жыл бұрын
Because there can be at most n-1 edges in the graph, so to resolve (relax) each edge length, we should take the worst case scenario.
@anubhavagrawal3963
@anubhavagrawal3963 4 жыл бұрын
Probably the best videos for graph theory on youtube. hats off.
@dardev8360
@dardev8360 Жыл бұрын
Thank you. I will be more active henceforth. Any ideas on how we can become more popular?
@s.d8756
@s.d8756 Жыл бұрын
@@dardev8360 Sir, use a facecam for your videos. It may help. also consistency can help. Create decent social media personality. Lastly, just put out quality content like this, nothing beats content. Once you put out content, it is just waiting for the masses to discover this beautiful channel.
@satyamchhatrala93
@satyamchhatrala93 4 жыл бұрын
Very nice playlist !! Highly Appreciated
@Mr_D0T
@Mr_D0T 2 жыл бұрын
Man you are a gem , i was so confused after reading solution in positive cycles
@dardev8360
@dardev8360 Жыл бұрын
Man, you are THE gem. You took out the time to write such a sweet comment. Any ideas on how we can become more popular?
@rounakagarwal1600
@rounakagarwal1600 3 жыл бұрын
Couldn't find the best video other than this on youtube
@amoghhuddar6408
@amoghhuddar6408 8 ай бұрын
Great work dude! Was so confused on why we require n-1 relaxations to propagate anything and you just explained it all so nicely. Thanks a lot man! Also some newer tc were added on cses like a graph with a single node with self loop with weight 1. You will have to run n relaxations on it cause n-1 is just 0. Do make more videos. Amazing Content❤
@youknowwho321
@youknowwho321 Жыл бұрын
solution starts at 29:00 ( For those who already knows Bellman-Ford's Algorithm)
@manusisodia5814
@manusisodia5814 9 ай бұрын
for those whose solution is not accepting add this condition if(n==1) { bool check=false; for(auto e: edges) { if(e.third
@m.e.t.a.l3125
@m.e.t.a.l3125 4 жыл бұрын
You are very much underrated! Awesome channel to learn Graphs..
@paragroy5359
@paragroy5359 4 жыл бұрын
Thanks for this playlist really helpful...
@dardev8360
@dardev8360 4 жыл бұрын
Cycle Detection in Directed Graph coming up in a few hours! Stay tuned and Stay updated
@loudcapricorn5513
@loudcapricorn5513 Жыл бұрын
Really very great learning video. 💯 Especially relating everything to past learned topics like Djikstra, BFS, etc
@dardev8360
@dardev8360 Жыл бұрын
Glad you liked it
@crazyfootball2271
@crazyfootball2271 4 жыл бұрын
The series is good. In this particular video , there is a mistake at 5:21. You have shown 2 graphs , Djikstra will work for the first one but not for the second one. Djisktra would only fail if there is a negative cycle (not a negative edge). Hence , it would work for example at 5:21.
@abhishekpandey7859
@abhishekpandey7859 3 жыл бұрын
yes that what i was also thinking
@yashbansal1520
@yashbansal1520 3 жыл бұрын
It will not work in case in case he is taking a visited array else if we are relaxing the nodes without a visited array it will work.
@jaishriharivishnu
@jaishriharivishnu 27 күн бұрын
seriously! you made it damn easy, I was complicating it.
@matheuscardoso1110
@matheuscardoso1110 4 жыл бұрын
this video is really great, congratz!
@manaskumarpanda3343
@manaskumarpanda3343 2 жыл бұрын
i'm addicted to your videos for cses problemset problems 💚
@dardev8360
@dardev8360 Жыл бұрын
That's how I want it to be! Stay addicted to the good stuff, man! Looking forward to suggestions.
@priyankarrajgupta4198
@priyankarrajgupta4198 4 жыл бұрын
Very well explained. I dont know why ur videos have such a low view count Are u using Windows XP ?
@dardev8360
@dardev8360 4 жыл бұрын
I also don't know why low view count. I use Windows 7 with Classic Theme.
@dardev8360
@dardev8360 4 жыл бұрын
Share more please? So my views increase and do subscribe!
@AnkitMishra-sq9nf
@AnkitMishra-sq9nf 4 жыл бұрын
@@dardev8360 sir, make your video titles that people will search for normally, dont put in video number as the first thing in your title , just give simple headings and ue keywords ony so that your channel is shown in search results....like "bellmanford algo" or "cses graph algo qustions"......there are more searches for bell man ford algo rather than csse playlist and even less searches for the big title that you generally put in your titles.....you can put rest of the info in your descriptions...
@pabitrakb5291
@pabitrakb5291 9 ай бұрын
Best postmortem of Bellman Ford algo ever possible ❤
@abhipatel13311
@abhipatel13311 3 жыл бұрын
Great content brother🙏🏻
@sibashissom3404
@sibashissom3404 25 күн бұрын
Thank you so much for this.
@nishuz
@nishuz 4 жыл бұрын
Nice video. But at 1:33, the path from 1 to 4 should be 4, not 2, right?
@dardev8360
@dardev8360 4 жыл бұрын
Right. Sorry! :( Thanks for pointing it out.
@s.d8756
@s.d8756 Жыл бұрын
Extremely Helpful video. Thanks a lot. Are your courses availabel on any other platforms? and why you have only videos on graph? Would love to see your vieos on other topics as well.
@androidguruji4542
@androidguruji4542 3 жыл бұрын
superb explanation really helpful , thank you . keep uploading new videos love to watch it........
@rupeshkataria81
@rupeshkataria81 Жыл бұрын
I have one doubt since there are m edges so we should start loop from 1 to m instead of 1 to n in bellman_ford function because your code fail for this input when n=1,m=1 and the edges are 1 1 1 . So edges start from 1 and end at 1 and the weight of edge is 1. its right answer is -1 but your code give 0 .Since for n=1 I our bellman_ford function would not run if I use m instead of n it give wrong output on many test cases
@haribooshan7457
@haribooshan7457 Жыл бұрын
I had just changed the number of iterations to max(n-1,1) instead of n-1. This seems to work.
@mohitahlawat4944
@mohitahlawat4944 Жыл бұрын
Dijkstra's will work if there is a negative edge. only thing is that the graph should not have any negative edge cycle
@anishsinghdhami2557
@anishsinghdhami2557 Жыл бұрын
It only worked, because of our implementation details. But according to the concept he taught it won't work because we won't be visiting or considering those vertices again which have been processed once(i.e. those vertices which is once taken out of the min_heap) will not be considered to do the relaxation for the remaining vertices. Hope the explanation makes sense if not do a google search and look for some of the stack-overflow articles.
@sachinsingh1956
@sachinsingh1956 4 жыл бұрын
this was a great solution i have ever seen.
@aadityaupadhyay6264
@aadityaupadhyay6264 4 жыл бұрын
Thanks for this video. Wonderful explanation
@dardev8360
@dardev8360 4 жыл бұрын
You are welcome Aaditya. I am impressed that you have kept up with the series! I will be making Floyd-Warshall and posting tonight! Stay tuned!
@aadityaupadhyay6264
@aadityaupadhyay6264 4 жыл бұрын
@@dardev8360 ya sure brother, waiting for more videos to learn the concepts
@159_mdamirulislam8
@159_mdamirulislam8 3 жыл бұрын
This man deserves more views and likes. Thanks.
@tarunjayadevan5981
@tarunjayadevan5981 3 жыл бұрын
sir you are amazing ! Thanks so much for such videos .... really helpful ..
@dardev8360
@dardev8360 Жыл бұрын
I am glad that I am able to help! Will make more content. What else would you like to see?
@raghavmittal5352
@raghavmittal5352 4 жыл бұрын
Great explanation
@sdmfslkdm
@sdmfslkdm 8 ай бұрын
if we are adding the cap to the dist[v] to inf , wouldn't it make it our answer to change
@bhanuprasadbellam3107
@bhanuprasadbellam3107 7 ай бұрын
Good explanation
@sommayghosh4617
@sommayghosh4617 2 жыл бұрын
I had a doubt your solution is correct and gets accepted , but the idea behind bellman ford is that after n-1 times , if we are again getting a shorter path for the nth time then there is a negative weight cycle but it doesn't get accepted few wrong answers came, but when i did like u , i.e again for n-1 times it got AC, can u tell the intuition behind it?
@yath3681
@yath3681 2 жыл бұрын
The negative weight cycle that we are getting should also be involved in the 'shortest path' from 1 -> n in our negated graph. If we found a negative cycle in our graph , but it is in no way involved ini the 'shortest path' , then the answer would not be -1.
@vinayverma8897
@vinayverma8897 2 жыл бұрын
Bro can you share the code pls
@shishankrawat2105
@shishankrawat2105 Жыл бұрын
"You may go through a tunnel several times." And we don't necessarily have to stop when we reach the Nth room. This means that if we can reach the Nth room with some distance, say d... and then from the Nth room back to room 1, such that now the distance of room 1 is less than 0. So we can re-iterate this path again and again. So, to confirm it what we can do is run cycle N times and then another (N-1) times and then finally see the distance values.
@dhairya7460
@dhairya7460 3 жыл бұрын
Sir I have a doubt please help me out. What's my claim is that if we reaches a node that doesn't have any outgoing edges we simply popout that node from priority queue so at the time of poping out if we mark that node as visited then we can't have to face negative cycle. Am i correct sir?
@KhemendraBhardwaj
@KhemendraBhardwaj Жыл бұрын
did you able to find it out?
@Rajjain_
@Rajjain_ 3 жыл бұрын
these are really good. thanks
@beonthego8725
@beonthego8725 2 жыл бұрын
Thank you Dardev
@dardev8360
@dardev8360 Жыл бұрын
You are welcome!
@kaukuntlaprudviraj108
@kaukuntlaprudviraj108 Жыл бұрын
Is it mandatory to convert the edge weights to it's negative form, in relaxation why can't we maximize the distance in place of minimizing
@optimus_prime01
@optimus_prime01 10 ай бұрын
do a dry run, that's how you learn
@madhvansharma5917
@madhvansharma5917 3 жыл бұрын
Hi, I had a question. I took INF as LLONG_MAX and NINF as -INF. I saw that the code didn't work for some testcases whereas when I took the values of INF and NINF same as in the video, then the Code executed nicely. Could u tell me why is that ?
@AkashKumar-im2zy
@AkashKumar-im2zy 3 жыл бұрын
It is due to overflow,(The maximum value that the variable can store is LLONG_MAX), LLONG_MAX+d will result in overflow, whereas some user-defined infinity like INF= 1e16 will not overflow because INF + u value is still less than the max size the long long variable can store!
@prime_edits007
@prime_edits007 4 жыл бұрын
well explained dude :P
@dardev8360
@dardev8360 4 жыл бұрын
Thanks, dude! :P
@paragsaini2795
@paragsaini2795 3 жыл бұрын
Your r awesome!! Great explanation. 🔥
@NiteshKumar-xm3nq
@NiteshKumar-xm3nq 6 ай бұрын
your code is giving wrong answers for self loops . try submitting it .
@litcode702
@litcode702 2 жыл бұрын
excellent...may I know from where you learnt in this much depth?? nowhere this kind of explanation is given
@dardev8360
@dardev8360 Жыл бұрын
Glad you liked the video. I learned stuff on my own. Do you want me to continue the series? :D
@lichuphy
@lichuphy Жыл бұрын
2 words: THANK YOU
@dardev8360
@dardev8360 Жыл бұрын
You are welcome! Subscribe for more!
@gantagourish7536
@gantagourish7536 2 жыл бұрын
I have a doubt. let the input be 5 5 1 2 1 2 3 1 3 4 1 4 2 1 4 5 1 according to your code it will give -1 because 2->3->4->2 will form negative cycle(as edges weight are converted to -ve) but when we draw graph on paper we can see path as 1->2->3->4->5 with score 4. can you explain please.
@anirbanghosh6328
@anirbanghosh6328 3 жыл бұрын
The solution link is not working
@kaukuntlaprudviraj108
@kaukuntlaprudviraj108 Жыл бұрын
it is failing at one test case
UFC 287 : Перейра VS Адесанья 2
6:02
Setanta Sports UFC
Рет қаралды 486 М.
She wanted to set me up #shorts by Tsuriki Show
0:56
Tsuriki Show
Рет қаралды 8 МЛН
Graph Theory Introduction Part 2 :: DFS and BFS
15:45
Dardev
Рет қаралды 3,4 М.
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 261 М.
Coding Adventure: Rendering Text
1:10:54
Sebastian Lague
Рет қаралды 825 М.
G-41. Bellman Ford Algorithm
27:43
take U forward
Рет қаралды 256 М.
Transformers (how LLMs work) explained visually | DL5
27:14
3Blue1Brown
Рет қаралды 4,5 МЛН