How do I represent the directed graph given below and traverse the following graph using the Breadth-first search (BFS) and depth-first search (DFS) algorithm?
Asked
Active
Viewed 45 times
0
-
Add your current approach as well – Abhinav Mathur Feb 23 '22 at 18:23
-
Use adjacency lists. – kiner_shah Feb 24 '22 at 06:09
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Feb 24 '22 at 08:00
-
Graph can be represented as adjacency list or adjacency matrix. Use adjacency list and use queue for BFS and do recursion for dfs maintaining a visited. Since you haven't provide any code only the simple logic can be given – Rohith V Feb 24 '22 at 13:29