Tag Archives: DFS

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
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 find the most frequent subtree sum that can be obtained by considering every node of the given… Read More
Given a Binary Tree, the task is to find the smallest subtree that contains all the deepest nodes of the given Binary Tree and return… Read More
Given a Binary Tree consisting of N nodes, the task to find the maximum average of values of nodes of any subtree. Examples:  Input:   … Read More
Given an integer N, the task is to find the path from the Nth node to the root of a Binary Tree of the following… Read More
Given a Binary Tree, the task is to remove the leaf nodes of the Binary Tree during each operation and print the count. Examples: Input:  … 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 an undirected graph with N vertices and N edges that contain only one cycle, and an array arr[] of size N, where arr[i] denotes… Read More
Given a Binary Tree, the task is to find the sum of all such nodes from the given tree whose sum of left and right… Read More
Given an N-ary tree rooted at 1, the task is to assign values from the range [0, N – 1] to each node in any… Read More
Given a string S of size N and a positive integer K ( where N % K = 0), the task is to find 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