# Tag Archives: Trees

## Count of distinct numbers in an Array in a range for Online Queries using Merge Sort Tree

Given an array arr[] of size N and Q queries of the form [L, R], the task is to find the number of distinct values… Read More »

## How to implement text Auto-complete feature using Ternary Search Tree

Given a set of strings S and a string patt the task is to autocomplete the string patt to strings from S that have patt… 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 »

## Nodes at Kth level without duplicates in a Binary Tree

Given a binary tree with N nodes and an integer K, the task is to print nodes of the Kth level of a binary tree… Read More »

## Sum of all the child nodes with even parent values in a Binary Tree

Given a binary tree, the task is to find the sum of all the nodes whose parent is even. Examples: Input: 1 / \ 3… Read More »

## Print all neighbour nodes within distance K

Given a graph of N nodes, E edges, a node X and a distance K. The task is to print all the nodes within the… Read More »

## Queries for the number of nodes having values less than V in the subtree of a Node

Given a rooted tree (assume root is 1) of N nodes and Q queries, each of the form (Val, Node). For each query, the task… Read More »

## Count the nodes of the tree which make a pangram when concatenated with the sub-tree nodes

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

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