No video

Detect Cycle in Undirected Graph | Using DFS | Cycle detection in Graph | DSA-One Course #77

  Рет қаралды 45,252

Anuj Bhaiya

Anuj Bhaiya

2 жыл бұрын

Hey guys, In this video, We're going to solve an important problem in Graphs called: Detect cycle in an Undirected Graph
Practice here: practice.geeksforgeeks.org/pr...
💸 Use coupon code ANUJBHAIYA on GeeksforGeeks to avail discounts on courses!
🥳 Join our Telegram Community:
Telegram channel: telegram.me/realanujbhaiya
Telegram group: telegram.me/dsa_one
🚀 Follow me on:
Instagram: / anuj.kumar.sharma
Linkedin: / sharma-kumar-anuj
Twitter: / realanujbhaiya
📚 Complete DSA Playlist: • DSA-One Course - The C...
Complete Android Development Playlist: • Android Development Tu...
Hashtags:
#anujbhaiya #dsaone
Tags:
detect cycle in undirected graph
detect cycle in an undirected graph
detect cycle in a undirected graph
cycle detection in undirected graph
anuj bhaiya
cycle detection in graph
detect cycle in graph
cycle in undirected graph
detect cycle in a directed graph
cycle in graph
graph data structure
graph dsa
undirected graph
cycle detection
anuj bhaiya java
cycle detection in directed graph
cycle in a graph
dsa one
cycle detection graph
graph in java
graph playlist
graphs dsa
cycle detection dfs
cycle detection striver
dfs
dfs graph
dfs in graph
dfs traversal
diameter of binary tree
dsa
find cycle in graph
finding cycle in a graph
floyd cycle detection
graph coding
graph cycle detection
graph in data structure
graph in dsa
java anuj bhaiya

Пікірлер: 45
@aishwaryshukla8880
@aishwaryshukla8880 Жыл бұрын
The way you do dry run after explaining the code, showing the white board side by side to the code editor is amazing! I don't know how did you get that idea but please know that it truly ensures that we have understood the code completely and easily. Please continue the good work and I hope you get whatever you want!
@JRK_RIDES
@JRK_RIDES 2 жыл бұрын
That DRY run at the end was very useful, would've been a little confused otherwise
@saniyapathan8968
@saniyapathan8968 27 күн бұрын
Best Explanation ever!
@tech_wizard9315
@tech_wizard9315 2 жыл бұрын
Please make a 60day roadmap for DSA beginner to crack tech giant's like Microsoft linkedin etc companies in 60days
@mnnitallahabad6753
@mnnitallahabad6753 Жыл бұрын
Impossible
@jatinkashyap9986
@jatinkashyap9986 Ай бұрын
Not impossible ​@@mnnitallahabad6753
@SauravNrai
@SauravNrai 2 жыл бұрын
You are amazing... Thank you so much
@akankshasrivastava3354
@akankshasrivastava3354 2 жыл бұрын
I like your dedication sir🙌
@sandeepdhiman9887
@sandeepdhiman9887 8 ай бұрын
very well explained
@saritaprasad4295
@saritaprasad4295 Жыл бұрын
very useful
@patelvivekshirinbhai5241
@patelvivekshirinbhai5241 Жыл бұрын
greate expaination
@shrutitibile5473
@shrutitibile5473 2 жыл бұрын
Sir all concept ke video bhejo dsa ke bahot help ho rhe hai isase
@Ravi-moq-6589
@Ravi-moq-6589 5 ай бұрын
The best❤
@ishantbhatia3194
@ishantbhatia3194 4 ай бұрын
nice
@piyushagarwal8458
@piyushagarwal8458 2 жыл бұрын
Guru Ji, Pranam !!
@AnujBhaiya
@AnujBhaiya 2 жыл бұрын
Pranam bro 🤙
@myinspiration4642
@myinspiration4642 Жыл бұрын
Hi Anuj, in DFS how we are maintaining parent node, Please explain
@chocolateandmath497
@chocolateandmath497 5 ай бұрын
int parent, we are not maintaining all parents
@dibyendudgp10
@dibyendudgp10 Жыл бұрын
I was thinking, union Find bhi to use kar sakte hai isme ? Ya koi edge case hai, jo unionFind cover nahi karega is case mei ? Uska complexity bhi to isse kam hi ana chahiye
@harishlodha8794
@harishlodha8794 2 жыл бұрын
Sir background video recorder app se record Kiya hua video app developer ke pass bhi store hota hai kya
@govindgupta290
@govindgupta290 Жыл бұрын
exact same is not working for me
@mrrishiraj88
@mrrishiraj88 2 жыл бұрын
🙏🙏
@gauravbanerjee2898
@gauravbanerjee2898 11 ай бұрын
Happy Teacher's day Bhaiya ❤️
@bhushanambhore8378
@bhushanambhore8378 2 жыл бұрын
Sir one doubt, where are you updating the parent variable of every vertex in your code? Initially, you set -1 as a parent of 0th vertex but after traversing the graph parent variable is supposed to be updated every time after visiting vertexes.
@divyanshpant169
@divyanshpant169 2 жыл бұрын
It's updated in the dfs function call when we pass V as parent argument
@piyushanand3451
@piyushanand3451 2 жыл бұрын
Same doubt.. please explain if you got it cleared.
@siddhantchavan1370
@siddhantchavan1370 2 жыл бұрын
when he recursively calls dfs, he passes the current node as the parent to the function.
@anchalsoni5892
@anchalsoni5892 Жыл бұрын
bhaiya smjh toh aa gya tha pr saare testcases pass nhi kiye
@abdulmajidshaikh300
@abdulmajidshaikh300 2 жыл бұрын
bhaiya code full nehi dekha jarahey , please when show code u can full display
@sayitavii
@sayitavii 2 жыл бұрын
search it on geeks for geeks you'll get the code almost the same
@comp_131_takshpatel9
@comp_131_takshpatel9 Жыл бұрын
Aapako bhaiya video me at run time coding karana chahiye , kyuki it is better
@l11_ayushkumar80
@l11_ayushkumar80 Жыл бұрын
sir code ke waqt word wrap kar diya karo naa thoda asaan ho jaata hai
@_sf_editz1870
@_sf_editz1870 6 ай бұрын
bhayya ke solution ke saamne kuch bol sakthe he kya
@mitadruchakraborty5184
@mitadruchakraborty5184 2 жыл бұрын
Bhai aapne jo code likha hai... usme I think "if(neighbor!=parent)" condition "if(!vis[neighbor])" condition se pahle hoga.... kiuki mai ye changes kiya then only mera 210/210 test cases run kar raha hai... Bhai can you check?
@annanyavijay4267
@annanyavijay4267 2 жыл бұрын
Mera to fir bhi run nhi kr rha
@raht9578
@raht9578 2 жыл бұрын
if nhi else if lagao
@Rebelx27
@Rebelx27 2 жыл бұрын
Bhaiya mujhe blockchain developer ban sakta hu kya ?
@suar_pilla
@suar_pilla 6 ай бұрын
aap kya ban paoge Bhaiya kaise bolega bhaya? Chu**** thik banega
@avinashsharma6286
@avinashsharma6286 2 жыл бұрын
always give the code
@newtanagmukhopadhyay4716
@newtanagmukhopadhyay4716 6 ай бұрын
class Solution { public: // Function to detect cycle in an undirected graph. bool ans = false; void dfs(int node, int parent, vector&visited, vectoradj[]){ visited[node] = true; for(int neighbour : adj[node]){ if(neighbour == parent) continue; if(visited[neighbour]==true){ ans = true; return; } dfs(neighbour, node, visited,adj); } return; } bool isCycle(int V, vector adj[]) { vectorvisited(V, false); for(int i=0; i
@Akaash449
@Akaash449 2 жыл бұрын
Kya Bhaiya aapka last name hai?
@abhi36292
@abhi36292 Жыл бұрын
no
@abhi36292
@abhi36292 Жыл бұрын
its bade bhaiya
@Akaash449
@Akaash449 Жыл бұрын
@@abhi36292 😂😂
@suar_pilla
@suar_pilla 6 ай бұрын
public boolean hasCycleUnDirected(T src) { return performDFSCycleDetection(src); } public boolean performDFSCycleDetection(T src) { // Key as Vertex, Value as its Parent Map visited = new HashMap(); Stack stack = new Stack(); visited.put(src, null); stack.add(src); while (!stack.isEmpty()) { T pop = stack.pop(); List neighbors = adjList.getOrDefault(pop, Collections.emptyList()); for (T neighbor : neighbors) { // if vertex is not visited if (!visited.containsKey(neighbor)) { visited.put(neighbor, pop); stack.add(neighbor); } else { // when vertex is already visited, //check who introduced the current element T vertexIntroducedBy = visited.get(pop); // parent of the current element // if parent is a neighbor or null (in case of starting position) // then its fine else there is a cycle. // in the case of A B, A's parent is null, // but B's parent is A. so when B's neighbors are being evaluated, // A is supposed to come as A is B's neighbor, // but it will not be a cycle as B as introduced by A if (vertexIntroducedBy == neighbor || vertexIntroducedBy == null) continue; else return true; } } } return false; }
Detect cycle in an undirected graph | Graph coloring method
7:42
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 120 МЛН
Inside Out Babies (Inside Out Animation)
00:21
FASH
Рет қаралды 24 МЛН
Советы на всё лето 4 @postworkllc
00:23
История одного вокалиста
Рет қаралды 4,8 МЛН
ТЫ С ДРУГОМ В ДЕТСТВЕ😂#shorts
01:00
BATEK_OFFICIAL
Рет қаралды 6 МЛН
Lecture 88: Cycle Detection in Undirected Graphs || Using BFS and DFS
32:03
CodeHelp - by Babbar
Рет қаралды 132 М.
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 809 М.
Breadth First Search (BFS): Visualized and Explained
10:41
Reducible
Рет қаралды 197 М.
Detect cycle in a directed graph
7:47
Techdose
Рет қаралды 139 М.
AES Explained (Advanced Encryption Standard) - Computerphile
14:14
Computerphile
Рет қаралды 1,2 МЛН
Cycle in Undirected Graph #InterviewBit || BFS , DFS & Union Find
24:15
Code with Alisha
Рет қаралды 3,1 М.
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 120 МЛН