Printing tree- segmentation fault

Hello @vashishthkuntal.gajjar2019 ther is mistake in input :


you have to input -1 to represent the node has no child further.

still having the same error- https://ide.codingblocks.com/s/424019

/bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe

give input this:
1 2 -1 -1 2 -1 -1
you have to add -1 to end nodes at that point.

ok got it but why 2 times -1 ?

because you have to tell that 2 neither have child at left and nor at right.

1 Like

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.