The visualization part of your code make you stand out of all the other instructor. Really it is quite easy to understand with the explanation . Thanks a lot for making such a great content and giving your time and energy to the community.
You are the best teacher because till now I did not find such a useful play list on graphs, as I face lots of difficulty in this topic but you cleared my all doubts. Thank-you luv bhai..
Thank You for explaining so nicely and for walking us through the implementation. Also, talking about log N factor that would come in picture if Djkstras is used was a masterstroke.
We might visit the node multiple levels but the first time you visit it , there is chance there is another edge with 0 wt at same level. Next encounters at different levels won't be processed as it will only increase the level of node. defeating shortest path💛
void bfs(int source) { level[source] = 0; queue q; q.push(source); while (!q.empty()) { int ver = q.front(); q.pop(); for (auto child : graph[ver]) { int x = child.first; int wt = child.second; if (level[ver] + wt < level[x]) { level[x] = level[ver] + wt; q.push(x); } } } } Here is my accepted code. To understand why deque is needed I have tried another video and book. I have tried for making an example not passed by the only queue. I failed. Why is this code correct? What is the case when a deque is needed?
May you can also do these topics with live stream... Save your editing and other effort and also less exhausting. (W/o doubts clearance through comment as it will make unnecessary big video )
wouldn't this go into infinite steps since there is no visited states for each node ? like or 1 i will insert 2 and then for 2 i will again insert 1 and so on
The visualization part of your code make you stand out of all the other instructor. Really it is quite easy to understand with the explanation . Thanks a lot for making such a great content and giving your time and energy to the community.
You are the best teacher because till now I did not find such a useful play list on graphs, as I face lots of difficulty in this topic but you cleared my all doubts. Thank-you luv bhai..
Thank You for explaining so nicely and for walking us through the implementation. Also, talking about log N factor that would come in picture if Djkstras is used was a masterstroke.
We might visit the node multiple levels but the first time you visit it , there is chance there is another edge with 0 wt at same level. Next encounters at different levels won't be processed as it will only increase the level of node. defeating shortest path💛
Got it , Took some time to explain myself how things are working here to find shortest path. Understood , Thank you.
11:23 This question is similar to Leetcode question - 1466. Reorder Routes to Make All Paths Lead to the City Zero.
Your explanation is great!
One of the most underrated but best instructor on RUclips. Your content is a hidden gem 💎💎
I was trying this question and my friend told to use this method...I didnt understand..thank god u posted a video on this.
ok
@@sriramkrishnamurthy4473 Ok
@@AdityaSingh-ql9ke not ok
As it is primarily a CP course plz try to add lca using binary lifting 🙏🙏
i can't thank you enough for putting out such an amazing content along with the wonderful explanations 🥺💛
Mtlb katai jehar bhaiya...love you bhaiya ❤
💛💛💛💛💛💛💛 Thank you bhaiya. Your playlist helped me a lot in strengthening my concepts.
.
Heart
superb explanation of the observation and thereby using it as a preruiqisite for this problem.
In the video of a algorithm topic where understanding the topic is the key. What is the necessity of using music? It causes distraction.
literally paused the video for 5 mins thinking why you added +1 instead of wt in 23rd line. lol xD, but appreciate your efforts bhaiya
I still didn't get why he added +1 instead of wt as the value of wt can also be equal to 0? Can you please explain?
At last he added wt instead of 1 it was a small mistake
Awesome explanation!
Excellent explanation!
very nicely explained and very nice problem.
so double ended queue is just used to prevent the log n time in case of priority queue as used in dijkstra, rest of the idea is similar to dijkstra
Peela dil 💛
Luv bhai ♥
What if we modify the graph and apply bfs normally ???
i have a question. is it mandatory to add wt in the if condition in 22nd line? it doesn't make any changes. the code will still work, right?
i have same Q did you solve it?
I am getting -1 in my sublime text and vs code but codeblocks and code chef i am got correct answer
same problem with my code in codeblocks
awesome💛💛💛💛
void bfs(int source)
{
level[source] = 0;
queue q;
q.push(source);
while (!q.empty())
{
int ver = q.front();
q.pop();
for (auto child : graph[ver])
{
int x = child.first;
int wt = child.second;
if (level[ver] + wt < level[x])
{
level[x] = level[ver] + wt;
q.push(x);
}
}
}
}
Here is my accepted code. To understand why deque is needed I have tried another video and book. I have tried for making an example not passed by the only queue. I failed. Why is this code correct? What is the case when a deque is needed?
Bro now I am confused too. :)
Bro did you find any answer?
It's easier to think with deque and probably queue takes more steps.
Bhaiya ji hm java basic kar chuke hai kya hm aapka ye DSA course dekh sakte hai
Please reply 🙏🙏🙏
Can we use Priority Queue to handle 0-1 part of the BFS.....?
May you can also do these topics with live stream... Save your editing and other effort and also less exhausting. (W/o doubts clearance through comment as it will make unnecessary big video )
🙏🏻 🙏🏻Sir, aap padhate waqt highlight krne ke liye konsa softwate use krte ho (jo laser jaisa dikhta hai phir apne aap gayab ho jata hai) 🙏🏻🙏🏻
Anyone know this??
@@GANESHSINGH-oe2wy not software bro,i phone ke notepad me features hai
@@sakshitiwari7835 😌 Ohh!! Thanks, i had never used that.. na.
@@GANESHSINGH-oe2wy Goodnotes
Bro advance concepts bhi cover kroge kya graphs ke ?
will cover dsu might not go more ahead than that
@@iamluv bro Y did U stop uploading the videos now ?
I wish if I had known this earlier!
can every 0-1 BFS problem be solved by Dijkstras ?
instead of INF can we also do int INT_MAX?
Any number will be safe greater than N. N and N-1 also.
Thanks :D
❤Thank You❤
wouldn't this go into infinite steps since there is no visited states for each node ? like or 1 i will insert 2 and then for 2 i will again insert 1 and so on
no babe i had the same doubt but read the code carefully no node is processed many times etc...
Yellow heart💛.
Bhaiya jab m Elon Musk ko hara dunga aur mera interview hoga to m bataunga ki maine aapki videos dekh ke cp sikha tha...
zameen pr aja thoda😂
@@utkarshgarg1755 bhai hum aasman m udne ke liye bne h :)
11-aug 2022
thanks brooo
Thanx bhaiya
Super
please read this, it will be level[child]=level[node]+wt, i wasted an hour and rewatched the video 3 times for this
@divy04 bro i can't understand why -1 is coming as output in program
how to solve this using djikstra??
yellow heart emoji nai he but ha watched till the end
hello guru ji please oop also start please guru ji thanks alot
itz better to apply dijkstra here using deque
Bro, pls make number theory for CP
Already hai
Bhai ap video ke sath notes dalthe tho hame or bhi accha lagtha padne keliye
👍👍
Bfs pe questions refer kro plz
there questions in previous 2-3 video descriptions
❤️
💛💛💛💛
❤❤❤
yellow heart
💛💛💛
❤️❤️
💛
first view
👍
💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛💛
💚
💛💛💛💛💛💛💛💛💛
💛💛💛💛💛💛💛
yeallow hart
💜💚💛💙
💛🌟💛
🧡🧡🧡🧡🧡
💞♥♥💞
💛💛💛
💛
💛💛💛💛
💛💛💛
💛
❤
💛💛💛
💛
🧡
💛
💛
💛
💛
💛
💛
💛
💛
💛
💛
💛
💛
💛
💛
💛
💛
💛
💛
🧡