Data Structure
Java
Python
HTML
Interview Preparation
Tutorials
Courses
Tracks
DSA
Practice Problems
C
C++
Java
Python
JavaScript
Data Science
Machine Learning
Courses
Linux
DevOps
Similar Topics
Web Technologies
32.1K+ articles
DSA
20.0K+ articles
Amazon
1.9K+ articles
Tree
911+ articles
array-range-queries
376+ articles
Binary Tree
330+ articles
Samsung
316+ articles
Advanced Data Structure
305+ articles
Binary Search Tree
166+ articles
Segment-Tree
156+ articles
LCA
38 posts
Recent Articles
Popular Articles
CSES Solutions - Distance Queries
Last Updated: 23 July 2025
Given a tree consisting of n nodes. The task is to process q queries of the form: What is the distance between nodes a and b?Examples:Input: n = 5, q = 2, edges = {{1, 2},...
read more
Competitive Programming
Picked
LCA
CSES Problems
Minimum operations to make all the edges of a path equal
Last Updated: 23 July 2025
Given a tree with N nodes and (N - 1) edges in the form of edges[], such that edges[i] = {u, v, w} denotes an edge from node u to node v with weight w. We are also given Q...
read more
Picked
DSA
LCA
Find Edge Weights in a Spanning Tree with Edge (u, v)
Last Updated: 23 July 2025
Given an undirected weighted graph with N nodes and M edges, the task is for each edge (u, v) find the minimum possible weight of the Spanning Tree which contains the edge...
read more
Picked
DSA
Trees
Kruskal'sAlgorithm
DFS
LCA
Geeks Premier League 2023
Binary Lifting
Last Updated: 26 August 2025
Binary Lifting is a Dynamic Programming approach for trees where we precompute some ancestors of every node. It is used to answer a large number of queries where in each q...
read more
Competitive Programming
Trees
LCA
Find the number of colored nodes according to given queries in a full Binary Tree
Last Updated: 12 December 2023
Consider a full Binary Tree where the root of the Tree is colored as Black initially. Each black-colored node will have red children, and red-colored nodes will have black...
read more
Tree
Geeks Premier League
DSA
LCA
Geeks Premier League 2023
Step by step Shortest Path from source node to destination node in a Binary Tree
Last Updated: 23 July 2025
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 shortest path from the st...
read more
DSA
Trees
Binary Tree
tree-traversal
LCA
Maximize sum of paths from LCA of nodes u and v to one of those nodes
Last Updated: 23 July 2025
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 exists an edge between node X and node Y with a weight o...
read more
Tree
Advanced Data Structure
Recursion
DSA
tree-traversal
DFS
LCA
n-ary-tree
Lowest Common Ancestor of the deepest leaves of a Binary Tree
Last Updated: 23 July 2025
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 of the deepest leaves of the binary ...
read more
DSA
tree-traversal
DFS
LCA
Second Best Minimum Spanning Tree
Last Updated: 15 July 2025
Given an undirected graph represented by the array edges[][], where each edges[i] contains three integers [u, v, w], representing an undirected edge from u to v, having di...
read more
DSA
Kruskal'sAlgorithm
Minimum Spanning Tree
MST
LCA
Check if two nodes are on same path in a tree | Set 2
Last Updated: 15 July 2025
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 tree.Example:Input: v1 = 1, v2 = 5 1 / | \ 2 3 4 ...
read more
DSA
Samsung
interview-preparation
LCA
Find distance between two nodes in the given Binary tree for Q queries
Last Updated: 15 July 2025
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 on the path between two nodes. Each query cont...
read more
DSA
Binary Tree
LCA.array-range-queries
LCA
Count of all prime weight nodes between given nodes in the given Tree
Last Updated: 12 July 2025
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 on the simple path between u and v (both inclus...
read more
DSA
sieve
Prime Number
LCA
Query to find the maximum and minimum weight between two nodes in the given tree using LCA.
Last Updated: 12 July 2025
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 and maximum weight on the simple path between u an...
read more
DSA
array-range-queries
LCA.array-range-queries
LCA
Lowest Common Ancestor for a Set of Nodes in a Rooted Tree
Last Updated: 12 July 2025
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 tree.Examples:Input: 1 ...
read more
DSA
DFS
LCA
Tree Traversals
Least Common Ancestor of any number of nodes in Binary Tree
Last Updated: 12 July 2025
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 all the key Nodes.Following is the definition ...
read more
DSA
Binary Tree
LCA
1
2
3