I seemed to be getting the right answer for nodes with single or no child but fails for nodes with 2 children
CAN YOU PLEASE TELL ME MY MISTAKE
Please tell me my mistake
hello @7nishit

here in place of left, it should be right.
similarly in place of right it should be left.
but my answer is still wrong for test case
1
3
1 2 3
1
2
answer should be 3 1
but im getting 1 3
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.
no, my doubt is not cleared.
Please clear the doubt that i asked about the difference in expected output and my output
Hello @7nishit,
No, the output should not be 3 1.
Let’s understand this with a diagram:
for the given input 1 2 3, the BST will look loki:
____1
_____
______2
_______
________3
So, on deleting 2,
the BST will become:
____1
_____
______3
The pre order traversal of the above will be: 1 3.
Hope, this will help.
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.