Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void findSwapped(Node n, Node result[]) {
- if (n == null) {
- return;
- }
- findSwapped(n.left, result);
- findSwapped(n.right, result);
- // if n is not a bst and one of it's child is not a bst then n is the
- // parent of problem
- if ((n.left != null && !n.left.isBST())
- || (n.right != null && !n.right.isBST())) {
- result[result[0] == null ? 0 : 1] = n;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement