https://online.codingblocks.com/player/12407/content/4764?s=2430
how are we supposed to build tree from the given input
https://online.codingblocks.com/player/12407/content/4764?s=2430
how are we supposed to build tree from the given input
Hey Manal, can you please share this problem’s exact name also as this link is not accessible.
Trees – Find sum at level K
Hey Manal, in this problem you are supposed to create a generic tree from the given input using build(). So, input is given in this way => first node data then the no. of child nodes it will be having. And at last Kth level is given at which you have to calculate the sum of nodes.
for eg.
input :
1 2
2 2
3 0
4 0
5 2
6 0
7 0
2
explanation : 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.
So, try to write a recursive function buildtree() for constructing this generic tree.