Question: Write the problem code in C + + & run it . Problem: Given a tree of n ( 1 < = n < =
Write the problem code in C & run it Problem: Given a tree of n n nodes labelled from to n
and an array of n edges where an edge a b indicates that
there is an undirected edge between the two nodes a and b in
the tree. Note that any node of the tree can act as a root.
The height of a rooted tree is the number of edges on the
longest path between the root and a leaf. When you select a
node x as the root, the resultant tree has height hx Among all
possible rooted trees, those with the minimum height are
called minimum height trees MHTs Print the roots of
all MHTs Constraints:
n
a b n
a b
All the pairs a b are distinct.
The given input is guaranteed to be a tree.
Input: n
Output:
Input: n
Output:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
