Question not clear 2

I am sorry to say but the questions are not framed in a good way. The question is asking to build a generic tree, right (not binary??); What is the pattern of such tree? How is the input for this generic tree to be taken. And how is the sum at level 2 20?

Hello @shubh17,

In Binary tree, binary means 2.
Thus, each node has can have 2 nodes at max, which is the constraint.

Generic Tree is a tree in which each node can have arbitrary number of children.
There is no constraint in the maximum number of children a node can have.
Also, each node can have different number of children.

Let’s now understand the question:
Given tree input:
1 2
2 2
3 0
4 0
5 2
6 0
7 0

1 2 means 1 has two child.
2 2 means 1 has first child 2 and 2 has 2 child
3 0 means 2 has first child 3 and 3 has 0 child
4 0 means 2 has second child 4 and 4 has 0 child
5 2 means 1 has second child 5 and 5 has 2 child
6 0 means 5 has first child 6 and 6 has 0 child
7 0 means 5 has second child 7 and 7 has 0 child

Tree at level 0 : _____________1
Tree at level 1 :_________2 ________5
Tree at level 2 : _____3______4__6_____7

Thus, sum at level 2 : 3+4+6+7=20

Hope, this would help.
Give a like, if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.