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

# Tag Archives: Graph Traversals

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 R and C, denoting the number of rows and columns in a matrix, and two integers X and Y, the task is… Read More

Given a Directed Graph consisting of N vertices and M edges and a set of Edges[][], the task is to check whether the graph contains… Read More

Given an adjacency list representation of a Graph, the task is to convert the given Adjacency List to Adjacency Matrix representation. Examples: Input: adjList[] =… Read More

Given an Undirected Graph consisting of N vertices and M edges, where node values are in the range [1, N], and vertices specified by the… Read More

Given a Directed graph of N vertices and M edges, the task is to find the minimum number of edges required to make the given… Read More

Given a weighted, directed graph G, an array V[] consisting of vertices, the task is to find the Minimum Cost Path passing through all the… Read More

Given an undirected and unweighted graph and two nodes as source and destination, the task is to print all the paths of the shortest length… Read More

Given an undirected graph with N vertices and M edges, the task is to print all the nodes of the given graph whose degree is… Read More

If the DFS finishing time f[u] > f[v] for two vertices u and v in a directed graph G, and u and v are in… Read More

Is following statement true/false? A DFS of a directed graph always produces the same number of tree edges, i.e., independent of the order in which… Read More

Is following statement true/false If a DFS of a directed graph contains a back edge, any other DFS of the same graph will also contain… Read More

Which of the following condition is sufficient to detect cycle in a directed graph? (A) There is an edge from currently being visited node to… Read More

Given two vertices in a graph s and t, which of the two traversals (BFS and DFS) can be used to find if there is… Read More