# Tag Archives: LCA

Given a root of binary tree and two integers startValue and destValue denoting the starting and ending node respectively. The task is to find theâ€¦ Read More
Given a tree consisting of N nodes an array edges[][3] of size N – 1 such that for each {X, Y, W} in edges[] thereâ€¦ Read More
Prerequisites – Graph, Spanning tree, Disjoint Set (Union – Find). A minimum spanning tree (MST) T, for a given graph G, spans over all verticesâ€¦ Read More
Given a Binary Tree consisting of N nodes having distinct values from the range [1, N], the task is to find the lowest common ancestorâ€¦ Read More
Given two nodes of a binary tree v1 and v2, the task is to check if two nodes are on the same path in aâ€¦ Read More
Given a binary tree having N nodes and weight of N-1 edges. The distance between two nodes is the sum of the weight of edgesâ€¦ Read More
Given a weighted tree containing N nodes, and two nodes u and v, the task is to find the count of nodes having prime weightâ€¦ Read More
Given a tree, and the weights of all the node. Each query contains two integers u and v, the task is to find the minimumâ€¦ 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
Given a binary tree (not a binary search tree) and any number of Key Nodes, the task is to find the least common ancestor ofâ€¦ Read More
Given a tree with N nodes and N – 1 edges. Each edge of the tree is labeled by a string of lowercase english alphabets.â€¦ Read More
Given three vertices U, V and R of a binary tree, the task is to check whether R lies in the path between U andâ€¦ Read More
Given a binary tree, the task is to find the Lowest Common Ancestor of the given two nodes in the tree. Let G be a treeâ€¦ Read More
Given a binary tree and two nodes a and b, the task is to print the minimum and the maximum node value that lies inâ€¦ Read More
Given a binary tree and two nodes of that binary tree. Find the sum of all nodes with odd values in the path connecting theâ€¦ Read More