Given a Binary Tree and an integer target, denoting the value of a node, the task is to find the sum of distances of all… Read More

# Tag Archives: Tree Traversals

Given a binary tree consisting of N nodes, the task is to find the sum of depths of all subtree nodes in a given binary… Read More

Given a 2D array edges[][] of type { X, Y } representing that there is an edge between the node X and Y in a… Read More

Given a Binary Tree, the task is to replace the value of each node with the sum of all the nodes present in the same… Read More

Given an integer N and an N-ary Tree of the following form: Every node is numbered sequentially, starting from 1, till the last level, which… Read More

Given a Binary Tree consisting of 0s and 1s only, the task is to print the count of levels in the Binary Tree in which… Read More

Given a Binary Tree, the task is to print the level order traversal of the tree after replacing the value of each node of the… Read More

Given a Binary tree consisting of N nodes with values in the range [1, N], the task is to find the distance from the root… Read More

Given an N-Ary tree, the task is to print all root to leaf paths of the given N-ary Tree. Examples: Input: … Read More

Given an N-ary Tree consisting of N nodes valued from 1 to N, an array arr[] consisting of N positive integers, where arr[i] is the… Read More

Given a Binary Tree consisting of N nodes and two integers R and K. Each edge of the tree has a positive integer associated with… Read More

Given an N-ary tree and an element X, the task is to print the siblings of the node with value X. Two nodes are considered… Read More

Given a Binary Tree and an integer K, the task is to delete nodes from the given Tree such that the sum of all nodes… Read More

Given a Binary tree, the task is to print all possible root-to-leaf paths having a maximum number of even valued nodes. Examples: Input: 2 /… Read More

Given a Binary Tree, the task is to count the number of nodes in the given Binary Tree such that the path from the root… Read More