Source Code:https://thecodingsimplified.com/check-if-directed-graph-has-cycle-using-dfs/
Solution:
- We'll achieve this via dfs (depth first search)
- With visited array, we'll also take recursiveStack array
- Whenever we visit the array, we mark the value True in visited Array
- If value is already in recursive stack, then we've cycle here.
- Else we put the the value true in recursiveStack array
- If we could not find cycle then we set value false in recursiveStack
CHECK OUT CODING SIMPLIFIED
https://www.youtube.com/codingsimplified
★☆★ VIEW THE BLOG POST: ★☆★
http://thecodingsimplified.com
I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.
★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
https://www.youtube.com/codingsimplified?sub_confirmation=1
★☆★ Send us mail at: ★☆★
Email: [email protected]