## Number of ways to paint a tree of N nodes with K distinct colors with given conditions

Given a tree with N nodes and a number K. Paint every node of the tree in one of the K available colors. Count and… Read More »

## Check if the given Prufer sequence is valid or not

Given a Prufer sequence of N integers, the task is to check if the given sequence is a valid Prufer sequence or not. Examples: Input:… Read More »

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

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

## Count the nodes of a tree whose weighted string does not contain any duplicate characters

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

## Print the degree of every node from the given Prufer sequence

Given a Prufer sequence, the task is to find the degrees of all the nodes of the tree made by the prufer sequence. Examples: Input:… Read More »

## 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 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 »

## 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 »

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

Given an array edge[][2] where (edge[i][0], edge[i][1]) defines an edge in the n-ary tree, the task is to print all the leaf nodes of the… 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 »

## 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 »