Given a directed graph, find out whether the graph is strongly connected or not. A directed graph is strongly connected if there is a path between any two pair of ve...

Share

What are BFS and DFS for Binary Tree?
A Tree is typically traversed in two ways:
Breadth First Traversal (Or Level Order Traversal)
Depth First Traversals
Inorde...

Share

Depth First Traversal (or Search) for a graph is similar to Depth First Traversal of a tree. The only catch here is, unlike trees, graphs may contain cycles, so we ...

Share

Given a directed graph, find out if a vertex v is reachable from another vertex u for all vertex pairs (u, v) in the given graph. Here reachable mean that there is a ...

Share

A tree consisting of n nodes is given, we need to print its DFS.
Examples :
Input : Edges of graph
1 2
1 3
2 4
3 5
Output : 1 2 4 3 5
...

Share

There are two common ways to traverse a graph, BFS and DFS. Considering a Tree (or Graph) of huge height and width, both BFS and DFS are not very efficient due to fo...

Share

Given a directed graph, find out whether the graph is strongly connected or not. A directed graph is strongly connected if there is a path between any two pair of ve...

Share

Given a boolean 2D matrix, find the number of islands. A group of connected 1s forms an island. For example, the below matrix contains 5 islands
Example:
Input : ma...

Share