Regarding the problem statement

Sir I was trying to make the tree with the input but segmentation fault is coming. Can you rectify the error?

you have to build generic tree here
not binary tree
so it will not have only 2 pointers left and right
but should have a array of pointers

Sir but it is written that the number of children won’t exceed two.

okay
actually your input is not correct
Correct input
1 2
2 2
3 2
4 0
5 2
6 0
7 0
8 0
9 0
3

Alright, thank you sir.

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.