
This updated information has been further expanded upon on my new website. You can find the updated details here: https://k5kc.com/cs/algorithms/recover-binary-search-tree-problem/.
Problem
Given a BST with 2 nodes swapped fix it.
Example
Consider the BST:
Following is the correct BST
10
/ \
5 20
/ \
2 8
Now we swap 8 and 20, and BST is changed.
Input Tree:
10
/ \
5 8
/ \
2 20
In the above tree, nodes 20 and 8 must be swapped to fix the tree....