# Tag Archives: DFS

## Conversion of an Undirected Graph to a Directed Euler Circuit

Given an undirected graph with V nodes (say numbered from 1 to V) and E edges, the task is to check whether the graph is… Read More »

## Print the nodes of the Binary Tree whose height is a Prime number

Given a binary tree, our task is to print the nodes whose height is a prime number starting from the root node. Examples: Input: 1… Read More »

## Count of unique lengths of connected components for an undirected graph using STL

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 »

## Count the nodes in the given Tree whose weight is a Perfect Number

Given a tree, and the weights of all the nodes, the task is to count the number of nodes whose weight is a Perfect number.… Read More »

## Count the nodes in the given tree whose weight is a powerful number

Given a tree, and the weights of all the nodes, the task is to count the number of nodes whose weight is a Powerful Number.… Read More »

## Count the number of walks of length N where cost of each walk is equal to a given number

Given a weighted undirected graph, Length of walks N and Cost X. The task is to count the number of different walks W of length… Read More »

## Lowest Common Ancestor for a Set of Nodes in a Rooted Tree

Given a rooted tree with N nodes, the task is to find the Lowest Common Ancestor for a given set of nodes V of that… Read More »

## Largest component size in a graph formed by connecting non-co-prime nodes

Given a graph with N nodes and their values defined in array A, the task is to find the largest component size in a graph… Read More »

## Minimum labelled node to be removed from undirected Graph such that there is no cycle

Given an undirected graph of N nodes labelled from 1 to N, the task is to find the minimum labelled node that should be removed… Read More »

## Count total ways to reach destination from source in an undirected Graph

Given an undirected graph, a source vertex ‘s’ and a destination vertex ‘d’, the task is to count total paths from given ‘s’ to ‘d’.… Read More »

## Minimum Cost of Simple Path between two nodes in a Directed and Weighted Graph

Given a directed graph, which may contain cycles, where every edge has weight, the task is to find the minimum cost of any simple path… Read More »

## Count nodes in the given tree whose weight is a fibonacci number

Given a tree with the weights of all the nodes, the task is to count the number of nodes whose weight is a Fibonacci number.… Read More »

## Minimum Bipartite Groups

Given Adjacency List representation of graph of N vertices from 1 to N, the task is to count the minimum bipartite groups of the given… Read More »

## Count ways to change direction of edges such that graph becomes acyclic

Given a directed and unweighted graph consisting of N vertices and an array arr[] where ith vertex have a directed edge to arr[i]. The task… Read More »

## Minimum value of distance of farthest node in a Graph

Given an acyclic undirected graph having N nodes and N-1 edges in the form of a 2D array arr[][] in which every row consists of… Read More »