Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago