# Tag Archives: DFS

Given a positive integer N denoting the number of astronauts(labelled from 0 from (N – 1))and a matrix mat[][] containing the pairs of astronauts that… Read More
Given a graph, G consisting of N nodes, a source S, and an array Edges[][2] of type {u, v} that denotes that there is an… Read More
Given a directed graph G consisting of N nodes and N-1 edges, and a positive integer K, and initially, all the nodes of the graph… Read More
Given a tree consisting of N nodes and rooted at node 1, also given an array Q[] of M pairs, where each array element represents… Read More
Given a binary matrix mat[][] of dimensions N*M, the task is to find the minimum number of flips required from the given binary matrix such… Read More
Given a Binary Tree consisting of N nodes, the task is to find the maximum width of the given tree where the maximum width is… Read More
Given an N-array Tree consisting of N nodes and an integer K, the task is to find the Kth largest element in the given N-ary… Read More
Given an array of pairs Edges[][], representing edges connecting vertices in a Tree consisting of N nodes, the task is to find the minimum time… Read More
Given a Directed Acyclic Graph with V vertices and E edges, the task is to find the set of dominant vertices for each vertex of… Read More
Given a Binary Tree consisting of N nodes, the task is to replace each node of the tree with the product of all the remaining… Read More
Given a Binary Tree consisting of N nodes, the task is to find the minimum number of cameras required to monitor the entire tree such… Read More
Given a Binary Tree consisting of N nodes having distinct values from the range [1, N], the task is to find the lowest common ancestor… Read More
Given an undirected weighted graph G consisting of N vertices and M edges, and two arrays Edges[][2] and Weight[] consisting of M edges of the… Read More
Given two graphs G1 and G2, the task is to find the union and intersection of the two given graphs, i.e. (G1 ∪ G2) and… Read More
Given a Binary Tree consisting of N nodes, the task is to find the number of paths from the root to any node X, such… Read More