Answered step by step
Verified Expert Solution
Question
1 Approved Answer
inc++ you are given a tree with n vertices.Each vartex i has a value ai associated with it. find the distinctive roots in the tree.
inc++
you are given a tree with n vertices.Each vartex i has a value ai associated with it.
find the distinctive roots in the tree.
input
the first line of the input contains a single integer n.the number of vertices in the tree.
the next line contains n - seperated integers.
the following n-1 lines each contain 2 seperated integer u and v.
output
print a single integer-the number of distinctive roots in the tree.
input
5
2 5 1 1 4
12
13
14
25
output
3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started