Given an n-ary tree T, the task is to find a node whose removal minimizes the maximum size of all forests(connected components) generated. Examples: Input: … Read More

# Tag Archives: DFS

Given an undirected graph G with N nodes, M edges, and an integer K, the task is to find the maximum count of edges that… Read More

Given an undirected graph with N vertices and K edges, the task is to check if for every combination of three vertices in the graph,… Read More

Given an N-ary tree and an integer K, the task is to print the Kth ancestors of all the nodes of the tree in level… Read More

Given a connected acyclic graph consisting of V vertices and E edges, a source vertex src, and a destination vertex dest, the task is to… Read More

Given a tree with N vertices numbered from 0 to N – 1, M edges, and Q queries of the form {U, V}, such that… Read More

Given an undirected graph consisting of N nodes containing values from the range [1, N] and M edges in a matrix Edges[][], the task is… Read More

Given an undirected graph G, with V vertices and E edges, the task is to check whether the graph is 2-edge connected or not. A… Read More

Given a N-ary tree with N vertices rooted at 1 and a set of vertices as V[], the task is to print any such vertex… Read More

Given a Tree having N nodes connected by N − 1 edge and a single disconnected node, the task is to find the diameters for… Read More

Given an Undirected Connected Graph in the form of a tree consisting of N nodes and (N – 1) edges, the task for each edge… 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 a Tree with N nodes values from 1 to N and N – 1 edges. The task is to find the maximum matching in… Read More

Given an Acyclic Undirected Graph in the form of a Binary Tree with the root at vertex 1 and values at each vertex [1, N]… Read More

Given an array arr[] representing a Generic(N-ary) tree. The task is to replace the node data with the depth(level) of the node. Assume level of… Read More