Skip to content

Tag Archives: DFS

Given a directed graph, a source vertex ‘s’ and a destination vertex ‘d’, print all paths from given ‘s’ to ‘d’. Consider the following directed graph.… Read More
Given a dictionary, a method to do lookup in dictionary and a M x N board where every cell has one character. Find all possible… Read More
Write a function that returns true if a given undirected graph is tree and false otherwise. For example, the following graph is a tree.  But… Read More
Given a snake and ladder board, find the minimum number of dice throws required to reach the destination or last cell from source or 1st… Read More
Given a directed graph and two vertices ‘u’ and ‘v’ in it, count all possible walks from ‘u’ to ‘v’ with exactly k edges on… Read More
Eulerian Path is a path in graph that visits every edge exactly once. Eulerian Circuit is an Eulerian Path which starts and ends on the… Read More
Given an undirected graph, how to check if there is a cycle in the graph? Example,  Input: n = 4, e = 4 Output: Yes Explanation: 0 1, 1… Read More
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… Read More
A vertex in an undirected connected graph is an articulation point (or cut vertex) iff removing it (and edges through it) disconnects the graph. Articulation… Read More
A directed graph is strongly connected if there is a path between all pairs of vertices. A strongly connected component (SCC) of a directed graph… Read More
Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge u v, vertex u comes before… Read More
A Bipartite Graph is a graph whose vertices can be divided into two independent sets, U and V such that every edge (u, v) either… Read More
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… Read More
Hamiltonian Path in an undirected graph is a path that visits each vertex exactly once. A Hamiltonian cycle (or Hamiltonian circuit) is a Hamiltonian Path… Read More
Given a directed graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least… Read More