Please I am getting segmentation fault please help me

You are getting segmentation fault because in your sample your having nodes from 0 to 8, so that is 9 nodes in total, but your parent array has space for only 8 nodes, so adjust accordingly.

Maybe this is how you want your code to work https://ide.codingblocks.com/s/428853

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.