How to check if exist pair $(a,b)$ of numbers in BST such that $|a-b| = d$, where $d$ is given.
contain of tree: $1, 4, 5, 3, 8, 45, 532$
answer: $yes$, there is pair $(5,8)$
I can solve it when number are in array - then I sort them, and in linear time I can find that pair. Neverthelress I can't idea how to augment BST in this task.
Can you give me a hint ?