Skip to content

Latest commit

 

History

History
 
 

recoverBinarySearchTree

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Problem

Two elements of a binary search tree (BST) are swapped by mistake.

Recover the tree without changing its structure.

Note: A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?

Solution

In-order traversal with validations