# Tag Archives: DFS

## Count the nodes of the given tree whose weight has X as a factor

Given a tree, and the weights of all the nodes, the task is to count the nodes whose weights are divisible by x. Examples: Input:… Read More »

## Count the nodes of the given tree whose weighted string is a palindrome

Given a tree, and the weights (in the form of strings) of all the nodes, the task is to count the nodes whose weights are… Read More »

## Count the nodes of the tree whose weighted string contains a vowel

Given a tree, and the weights (in the form of strings) of all the nodes, the task is to count the nodes whose weights contain… Read More »

## Difference between BFS and DFS

Breadth First Search BFS stands for Breadth First Search is a vertex based technique for finding a shortest path in graph. It uses a Queue… Read More »

## Count the nodes in the given tree whose weight is even parity

Given a tree and the weights of all the nodes, the task is to count the number of nodes whose weights are even parity i.e.… Read More »

## Print all leaf nodes of an n-ary tree using DFS

Given an array edge[] where (edge[i], edge[i]) defines an edge in the n-ary tree, the task is to print all the leaf nodes of the… Read More »

## Minimum number of pairs required to make two strings same

Given two strings s1 and s2 of same length, the task is to count the minimum number of pairs of characters (c1, c2) such that… Read More »

## Find the root of the sub-tree whose weighted sum XOR with X is maximum

Given a tree, and the weights of all the nodes, the task is to find the root of the sub-tree whose weighted sum XOR with… Read More »

## Count the nodes whose sum with X is a Fibonacci number

Given a tree, and the weights of all the nodes and an integer X, the task is to count all the nodes i such that… Read More »

## Count the nodes whose weight is a perfect square

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

## Find the node whose sum with X has minimum set bits

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 »

## Find the node whose absolute difference 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 »

## Find the node whose sum with X has maximum set bits

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 »

## Find the node whose absolute difference with X gives maximum 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 »

## Find the node whose xor with x gives maximum 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 »