Build tree (Generic)

Not able to understand how to buidtree using sample input

please check this code you will get idea to how to build the tree

https://ide.codingblocks.com/s/62401

can you tell me where i am going wrong

https://ide.codingblocks.com/s/62409

what exactly you are trying to do in sumf function and what is k

k is level of which i have to find sum i am trying to find sum of kth level in sumf

https://ide.codingblocks.com/s/62505 there was small logical error