# Category Archives: Tree

Given a Binary tree, the task is to find the number of visible nodes in the given binary tree. A node is a visible node… Read More
Given a binary tree, our task is to print the nodes whose height is a prime number starting from the root node. Examples: Input: 1… Read More
Given a string str which contains pairs of balanced parentheses, the task is to calculate the score of the given string based on the given… Read More
Given a Tree, the task is to find the farthest node from each node to another node in this tree.  Example: Input: Given Adjacency List… Read More
Given a binary tree consisting of distinct values and two numbers K1 and K2, the task is to find all nodes that lie between them… Read More
Given a tree, and the weights of all the nodes, the task is to count the number of nodes whose weight is a Perfect number.… Read More
Given a tree, and the weights of all the nodes, the task is to count the number of nodes whose weight is a Powerful Number.… Read More
Given two arrays A[] and B[] containing N elements, the task is to find, for every element in the array B[], the element which is… Read More
Given a Prufer sequence of a Tree, the task is to print the nodes with prime-degree in this tree.Examples:   Input: arr[] = {4, 1, 3,… Read More
Given a binary tree, the task is to print all the nodes having exactly one child. Print “-1” if no such node exists.Examples:  Input: 2… Read More
Given an array of N integers, the task is to perform the following two operations on the given array:   query(L, R): Print the number of… Read More
Given a Binary Tree, the task is to print all root-to-leaf paths of this tree whose xor value is non-zero. Examples:  Input: 10 / \… Read More
Given a binary tree with N nodes numbered [1, N], the task is to find the size of the smallest Dominating set of that tree.… Read More
The data structure is a way of storing and organizing data efficiently such that the required operations on them can be performed efficiently concerning time… Read More
Given a rooted tree with N nodes, the task is to find the Lowest Common Ancestor for a given set of nodes V of that… Read More