## GCD from root to leaf path in an N-ary tree

Given an N-ary tree and an array val[] which stores the values associated with all the nodes. Also given are a leaf node X and… Read More »

## Find the node whose xor with x gives minimum value

Given a tree, and the weights of all the nodes and an integer x, the task is to find a node i such that weight[i]… Read More »

## Minimum steps to color the tree with given colors

Given a tree with N nodes which initially have no color and an array color[] of size N which represent the color of each node… Read More »

## Check if a directed graph is connected or not

Given a directed graph. The task is to check if the given graph is connected or not. Examples: Input: Output: Yes Input: Output: No Recommended:… Read More »

## Program to count Number of connected components in an undirected graph

Given an undirected graph g, the task is to print the number of connected components in the graph. Examples: Input: Output: 3 There are three… Read More »

## Find the Kth node in the DFS traversal of a given subtree in a Tree

Given a tree with N nodes, and two integers K and V. The task is to find the Kth node in the DFS traversal of… Read More »

## Find number of edges that can be broken in a tree such that Bitwise OR of resulting two trees are equal

Given a tree with n nodes and a number associated with every node. We can break any edge of the tree which will result in… Read More »

## Longest path in a directed Acyclic graph | Dynamic Programming

Given a directed graph G with N vertices and M edges. The task is to find the length of the longest directed path in Graph.… Read More »

## Even size subtree in n-ary tree

Given an n-ary tree of n vertices and n-1 edges. The tree is given in the form of adjacency list. Find number of subtrees of… Read More »

## Number of special nodes in an n-ary tree

Given an n-ary tree rooted at vertex 1. The tree has n vertices and n-1 edges. Each node has a value associated with it and… Read More »

## Number of connected components in a 2-D matrix of strings

Given a 2-D matrix mat[][] the task is count the number of connected components in the matrix. A connected component is formed by all equal… Read More »

## Print the lexicographically smallest DFS of the graph starting from 1

Given a connected graph with N vertices and M edges. The task is to print the lexicographically smallest DFS traversal of the graph starting from… Read More »

## Number of unique paths in tree such that every path has a value greater than K

Given a tree as set of edges such that every node has unique value. We are also given a value k, the task is to… Read More »

## Find the maximum value permutation of a graph

Given a graph containing N nodes. For any permutation of nodes P1, P2, P3, …, PN the value of the permutation is defined as the… Read More »

## Minimum edges to be added in a directed graph so that any node can be reachable from a given node

Given a directed graph and a node X. The task is to find the minimum number of edges that must be added to the graph… Read More »