Category Archives: Graph

Print the node with the maximum degree in the prufer sequence

Given a Prufer sequence of a Tree, the task is to print the node with the maximum degree in the tree whose Prufer sequence is… Read More »

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 in the given tree whose sum of digits of weight is odd

Given a tree, and the weights of all the nodes, the task is to count the number of nodes whose sum of digits of weights… 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 »

Count the nodes in the given tree whose weight is a power of two

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

Find the root of the sub-tree whose weighted sum is minimum

Given a tree, and the weights of all the nodes, the task is to find the root of the sub-tree whose weighted sum is minimum.… 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 »

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

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 in the given tree whose weight is even

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

Count the nodes in the given tree whose weight is prime

Given a tree, and the weights of all the nodes, the task is to count the number of nodes whose weight is prime. Examples: Input:… 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 »