Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. static void findSwapped(Node n, Node result[]) {
  2. if (n == null) {
  3. return;
  4. }
  5. findSwapped(n.left, result);
  6. findSwapped(n.right, result);
  7.  
  8. // if n is not a bst and one of it's child is not a bst then n is the
  9. // parent of problem
  10. if ((n.left != null && !n.left.isBST())
  11. || (n.right != null && !n.right.isBST())) {
  12. result[result[0] == null ? 0 : 1] = n;
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement