DOUBT IN PROBLEM STATEMENT IN QUESTION--"Trees--Find sum at level K"

I am not able to understand the sample input given in the problem i.e what do the left-side values and right-side values signify and how at level 2 sum is 20.
I am able to get that right side 0 signifies 0 children and right side 2 signifies 2 children and according to this at level 2 we have 2 and 3 values so how sum is 20 at level 2.
please help in understanding problem input.
thanks in advance sir/ma’am.

Hey Nikhil, in this problem we are taking input for a generic tree, at each step you are getting the node’s data and how many children it would have. For eg.
input:
1 2
2 2
3 0
4 0
5 2
6 0
7 0
2

Here 1 2 denotes 1 is root node data and it will be having 2 child then
2 2 denotes 1 is root node data and it will be having 2 child then
3 0 denotes 1 is root node data and it will be having 0 child,
similarly it goes on and at last 2 denotes the level at which you have to calculate the sum of nodes.

Level order of this tree:
level 0: 1
level 1: 2 5
level 2: 3 4 6 7

Hi Nikhil,


Here is the tree. The values on the left side are the values of the nodes and the values on the right side are the number of children of that node.

Hey Nikhil, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “Ask Doubt” section, when your doubt is resolved.