Code not working properly

Link to my code

@jatin111,

your logic of sorting and building the tree won’t work because the question does not want you to sort the array, it just wants that you insert the nodes in order they are coming according to whether they should be placed in left or right subtree based on data value.

I have attached the code for node insertion in the tree that should be followed. Please refer to it:

can you please do the corrections in my code

@jatin111,
Did you update the insertion part? If yes, please share the updated code.

link to my updated code https://ide.codingblocks.com/s/326264

@jatin111,
https://ide.codingblocks.com/s/326863 corrected code

I have added comments on the lines I have added for your reference. You missed on test cases if parent is null

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.