Given a matrix A[][] of size N * M columns each element consists of either 0 representing free space and 1 representing wall. In one… Read More
Tag Archives: Algorithms-Graph Traversals
Given an integer N denoting the number of connected cities ( numbered from 1 to N ) and a 2D array arr[][] consisting of pairs… Read More
Tarjan’s Algorithm: The Tarjan’s Algorithm is an efficient graph algorithm that is used to find the Strongly Connected Component(SCC) in a directed graph by using… Read More
Given a Directed Acyclic Graph having V vertices and E edges, where each edge {U, V} represents the Jobs U and V such that Job… Read More
Given a binary matrix mat[][] of dimensions NxM such that 1 denotes the island and 0 denotes the water. The task is to find the… Read More
Given two integers V and E representing the number of vertices and edges of an undirected graph G(V, E), a list of edges EdgeList, and… Read More
Given an undirected weighted graph of N nodes and M edges in the form of a tuple lets say {X, Y, Z} such that there… Read More
Given an undirected graph having N vertices and M edges and each vertex is associated with a cost and a source vertex S is given.… Read More
Parenthesis Theorem is used in DFS of graph. It states that the descendants in a depth-first-search tree have an interesting property. If v is a… Read More
Given an undirected graph, the task is to find the size of each connected component and print the number of unique sizes of connected components … Read More
Given an undirected graph, a source vertex ‘s’ and a destination vertex ‘d’, the task is to count the total paths from the given ‘s’… Read More
Given a directed graph. The task is to check if the given graph is connected or not.Examples: Input: Output: YesInput: Output: No Recommended: Please… Read More
Given a connected graph with N vertices and M edges. The task is to print the lexicographically smallest DFS traversal of the graph starting from… Read More
Given a connected graph with N vertices and M edges. The task is to print the lexicographically smallest BFS traversal of the graph starting from… Read More
Given an undirected graph G(V, E) with N vertices and M edges. We need to find the minimum number of edges between a given pair… Read More