Practice
Resources
Contests
Online IDE
New
Free Mock
Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Scaler
Explore Offerings by SCALER

Go to Problems

# Graph Traversals ( DFS and BFS )

Now that we have looked at graph and some of its properties, we will try to explore how to traverse the graph and search for a particular node.
There are 2 popular approaches of doing graph traversals :
* Depth first search ( DFS )
* Breadth first search ( BFS )
We will take a look at them in this video :

## Serious about Learning Programming ?

Learn this and a lot more with Scaler Academy's industry vetted curriculum which covers Data Structures & Algorithms in depth.

## Graph Data Structure & Algorithms Problems

Graph traversal
Problem Score Companies Time Status
Path in Directed Graph 150 40:56
Water Flow 200
71:00
Stepping Numbers 300 60:28
Capture Regions on Board 500
66:16
Word Search Board 500 59:35
Depth first search
Problem Score Companies Time Status
Path with good nodes! 150 59:12
Largest Distance between nodes of a Tree 200
78:20
Good Graph 200
62:30
Cycle in Directed Graph 200 55:58
Delete Edge! 200 66:03
Two teams? 300 53:53
Bfs
Problem Score Companies Time Status
Valid Path 200 84:23
Region in BinaryMatrix 200 45:04
Path in Matrix 200 28:38
Level Order 300 29:55
Smallest Multiple With 0 and 1 300 75:15
Min Cost Path 300 67:34
Permutation Swaps! 300 57:01
Graph connectivity
Problem Score Companies Time Status
Commutable Islands 200 77:45
Possibility of finishing all courses given pre-requisites 200 64:40
Cycle in Undirected Graph 200 53:10
Mother Vertex 200 52:58
File Search 200 21:40
Black Shapes 300 48:55
Problem Score Companies Time Status
Convert Sorted List to Binary Search Tree 300
44:40
Shortest path
Problem Score Companies Time Status
Sum Of Fibonacci Numbers 300
53:01
Knight On Chess Board 300 67:43
Useful Extra Edges 400 63:12
Graph hashing
Problem Score Companies Time Status
Clone Graph 500 57:06

Problem Score Companies Time Status
Connected Components 200 22:29
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Select an option *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *