diff --git a/Graph_Algorithms/src/Depth_First_Traversal/Graphs.md b/Graph_Algorithms/src/Depth_First_Traversal/Graphs.md new file mode 100644 index 00000000..8a32bd78 --- /dev/null +++ b/Graph_Algorithms/src/Depth_First_Traversal/Graphs.md @@ -0,0 +1,53 @@ +

Graphs

+ +Q1) Islands + +#### An island is a small piece of land surrounded by water . A group of islands is said to be connected if we can reach from any given island to any other island in the same group . Given N islands (numbered from 1 to N) and two lists of size M (u and v) denoting island u[i] is connected to island v[i] and vice versa . Can you count the number of connected groups of islands. + +```c++ + +void dfs(int curr, int* visited, int** adj_matrix, int n){ + visited[curr] = 1; + for(int i = 0; iu,vectorv) +{ + int** adj_matrix = new int*[n]; + for(int i = 0; i