Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question:: Tree Parents Subset You are given a tree rooted at node 1 with N nodes. Each node i has a value C [ i

Question:: Tree Parents Subset
You are given a tree rooted at node 1 with N nodes. Each node i has a value C[i-1].
You need to choose a subset of nodes that satisfies the following conditions.
1. For any two nodes u, v of the chosen subset, if node "w" is a common ancestor for u and v, then dist(u,w)!= dist(v,w).
2. For any two nodes u, v of the chosen subset where dist(u, root)= dist(v, root)-1, then parent[v]!= u.
The value of the subset is the sum of the values of the chosen nodes.
Find the maximum possible value of a chosen subset. SInce the answer may be large return it modulo 10^9+7.
Input Format:
The first line contains an integer N, denoting the number of elements in C.
the next line contains an integer M, denoting the number of rows in edges.
The next line contains an integer, Two, denoting the number of columns in edges.

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

Step: 3

blur-text-image

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

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions

Question

4. Identify the stage of the road of trials in The Wizard of Oz.

Answered: 1 week ago