Question: You are given a tree ( a connected, undirected graph with no cycles ) consisting of n nodes numbered from 0 to n - 1
You are given a treea connected, undirected graph with no cycles consisting of n nodes numbered from to n and also an array weight of length n such that weighti represents the weight of ith node. You are also given d integer ar
ray edges where edgesiXy means there exists an undirected edge between x and y For each pair ij of node you have to sum the weight of node with the minimum value that occurs in the simple path between i and j For example from node to Lode there exists node with weight in the path between the node and node and this weight is minimum so we have to add this value in our result so finally we sum the minimum weights of node that occurs in path for each pair of nodes and return that value.
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
