BST - Sufficient condition for connecting a node to a parent Let's assume that we have a binary search tree with node Y that hasn't a right child and for whom a successor exists in the tree.

I want to prove that if I insert a node X into the tree and node X is greater than node Y and less than the successor of node Y then X will be added as the right child of Y.

Intuitively, this makes sense to me but my question is how do we prove this formally?
Due to the lack of definitions in the question, let us pick up a couple of definitions that are needed for a formal proof.


  A binary rooted tree is a BST if its nodes are visited in its natural order by the inorder traversal. Inserting a new node into a BST means adding a new edge so that the new node becomes the child of some old node and the tree remains a BST.




Let us prove a useful lemma.
(Uniqueness of insertion into BST) Let $T$ be a BST. Let node $X$ be a new node that is not equal to any node in $T$. Then there exists a unique way to insert $X$ into $T$ so that $T$ remains a BST with the same root, where the insertion must add one edge to $T$ (without modifying the existing edges).

Proof by mathematical induction on $n$, the number of vertices in $T$.


The base case when $n=1$. If the new node is less than the root node, it has to inserted as the left child of the root node; otherwise, it has to be inserted as the right child of the root node.
Assume the lemma is true for BST whose number of vertices is smaller than $n$. Suppose $T$ is a BST of $n$ vertices with node $R$ as its root node. Suppose $X$ is a new node that is not equal to any node of $T$. There are two cases.


$X$ is less than $R$. If $R$ has no left child, then $X$ has to be inserted as the left child of $R$. Otherwise, $R$'s left subtree is a BST (because of the recursive nature of the inorder traversal). $T$ has to be inserted into $R$'s left subtree. By induction hypothesis, there exists a unique way to insert $X$ into $R$'s left subtree.
$X$ is greater than $R$. Just switch every "left" to "right" in the above case.



Proof is done. As you have indicated, this is intuitively so obvious!



Now let us prove a proposition that is slightly more general than what you want to prove.
(Right child insertion) Let $T$ be a BST with node $Y$ that does not have a right child. Let node $X$ be a new node larger than $Y$ such that any node that is larger than $Y$, if exists, must be larger than $X$. Then node $X$, if inserted, will be inserted as the right child of $Y$.

Proof. Let $T'$ be the binary tree obtained from $T$ when $X$ is added as the right child of $Y$. Compare the inorder traversal on $T$ and that on $T'$. By the definition of inorder traversal, the difference between them can happen only when each traverses the subtree rooted at $Y$. 

Both traversals will visit the same left subtree of $Y$ first. Then both will visit $Y$.  When it is time to visit the right subtree of $Y$, the former traversal has nothing to do since $Y$ has no right child in $T$ while the latter traversal will visit one more node, $X$ since $Y$ has $X$ as its right child in $T'$.

Since the nodes in $T$ is visited in its natural order by the former traversal, the nodes in $T'$ is visited in its natural order by the latter traversal as $X$ is the very next node that is larger than $Y$. By definition, $T'$ is a BST. According to the above uniqueness lemma, $X$ must be inserted as the right child of $Y$. Q.E.D.