Solution: Find Minimum Diameter After Merging Two Trees
Explore how to find the minimum diameter of a combined tree formed by connecting two trees with a single edge. Learn to apply breadth-first search twice to determine each tree's diameter and use a formula that minimizes the combined diameter. Understand the BFS technique for tree diameter calculation and time and space complexity considerations in this problem-solving lesson.
We'll cover the following...
Statement
You are given two undirected trees: one with edges1 of length edges2 of length edges1[i] = [aᵢ, bᵢ] represents an edge between nodes edges2[i] = [uᵢ, vᵢ] represents an edge in the second tree.
Your task is to connect any node from the first tree to any one node from the second tree using a single ...