Lecture 92: Cycle Detection in Directed Graph || Using BFS

preview_player
Показать описание
In this Video, we are going to learn about Cycle Detection in Directed Graphs using BFS.

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:

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
Рекомендации по теме
Комментарии
Автор

Okay so to clarify the (cnt == N) logic. Although it was a great explaination.
In Kahn's algorithm, a node only enters the queue if its indegree becomes zero and then it further decrements the indegree values of its adjacent nodes right. But in the case of cyclic graph, there will be a node from where the cycle will be starting and then coming to an end.
So in order for the elements present in the cycle to get pushed into the queue, that cycle starting node's indegree must become zero right. But but but, that node's indegree will never become zero as one of the node from the cycle (the second last element) will be pointing towards the starting node. Just imagine with a diagram in the video. So if that node's indegree will never become zero, then it will restrict its adjacent nodes (at least) to get evaluated and hence the total number of nodes getting pushed into the queue (cnt) will never become (=N).

kamaldhakad
Автор

For folks running loop from i=1 to i<=n, declare vector<int> indegree(n+1) size to avoid Runtime Error.

sal
Автор

Relax boiiis... Babbar bhaiya sb ki placement lgwa k dam lenge..
love++❤️... #dsabusted #dbms #os

VivekKumar-veuc
Автор

Yhi chahiye bhaiya, aise hi daalte raho..hum sab cover kar rhe 🔥🔥🔥

simplesolutions
Автор

too fast 2 furious, consistency level 100 bhaiyya 🔥🔥

harishsoni
Автор

Now this is Fast and Furious ... 5 videos in a row.🔥🤩

Edit : Thanks Love bhaiya for the heart 🤍

Edit 2 : I got a heart from Love Bhaiya. I edit to add above line. YouTube removed the heart ! 🥺🥺💔

HeyMr.OO
Автор

Bhaiya kamal kar deya aik din course 3 videos wow kamal 😍❤❤❤

hilmand
Автор

public class DSACourseBYLoveBabbar{

public static void main(String args[]){

System.out.println("This question is Easy++");

System.out.println("This DSA course has infinity cosistency and lot of learning . Thanku very much Bhaiya for this course ❤❤❤💛🧡💗");
}
}

shivakashyap
Автор

Graph topics explanation is really good. I was facing issues in understanding graphs algorithm. Thanks a lot Babbar.

siddharthkhandelwal
Автор

Consistency Super OP 👌 🤩🤩🔥 Bass Ab Yhi Consitency Chahiye Bhaiyya Till The End of the Course . 😀🙂🙂🙂

ShouryaPant
Автор

consistency level ="infinity" 👌👌😎😎

raghavattri
Автор

Mark the attendance bhaiya🔥❤️
*_#DSAbusted_*
*_**#BELIEVEINBABAR** _*
😊🔥❤️

dEviL_bIsWaJiT
Автор

Clearing the meaning of (cnt == n) logic .
. cnt keeps track of the number of nodes processed (or visited) during the BFS-based topological sorting.
. If all nodes are processed (cnt == adj.size()), it means the graph is acyclic.
. If some nodes are left unprocessed (cnt != adj.size()), it indicates the presence of a cycle.
I thinkk this is the is meaning of that "if logic"

DhirajKumar-wms
Автор

I had solved this question without watching this video thank you so much bhaiya

abhijeetbasfore
Автор

We can also write

if(ans.size() == n) 🤷‍♂

Deepanshu__
Автор

khatarnak explanation bhaiya sab clear ho gaya

thinker-op
Автор

Great explanation, very easy to understand.

varungurnani
Автор

Bhaiya Course rukk gya video nhi aa rhi 😢

Le babbar bhaiya 3 videos in a day 😂😂

unboxtheuniverse
Автор

maza aa rha h bhiaya 🤟🤟and consistency is op as usual

vijeas
Автор

4th vdo for today .. trying to complete this series 48 vdos left in 9 days as after that placement is starting

KhushiKavya-pyyj
visit shbcf.ru