Remove BST Keys in a given Range

I am having problem understanding the concept mainly with recursion part.

The approach given in this link says: “When we visit a node, we make sure that its left and right sub-trees are already fixed.”

now my question is, why are we fixing the right and left sub tree?

hello @aavruty_dhir

they are not fixing anything. What they mean to say is remove the tree in post order fashion.
its becuase deletion of node will change the structure ,ie when there is need of deletion of root then in that case we need to connect left subtree with right subtree .
and if they themselves contains keys (to be deleted) then again this connection(between left and right subtree) might not hold becuase the connecting nodes might themselves get deleted.
so its better to first remove from left and right subtree and then comes to root.
hence the preordr

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.