Delete node in BST

All Test cases getting failed. Please check the code.
Code Link: https://ide.codingblocks.com/s/320074.
Thanks in advance.

@naivecoder010
You are building the tree wrong. You are not supposed to sort the array and then build the bst. You are expected to insert nodes in the bst in the order they come enter the array. It means in the sample example given, 5 will be set to be the root of the tree.

Please revert if you face any difficulty.
If my solution is able to answer your query, please mark the doubt as resolved.

Thanks for explanation @LP18Aug0068 but still not getting correct output.
Code Link: https://ide.codingblocks.com/s/320074. Okay a small mistake. Done.

@naivecoder010
Did the code work out?

No sorting array was wrong.

@naivecoder010
Yes just insert the nodes in the tree in the order they are given in the array.