public static void recoverTree(TreeNode root) {
        List<TreeNode> nodes = new ArrayList<TreeNode>();
        traversal(root, nodes);
        for (TreeNode tn : nodes) {System.out.print(tn.val + " ");}
        int i = 0;
        int index1 = -1;
        int index2 = -1;
        for (i = 0; i < nodes.size() - 1; i++) {
        	if (nodes.get(i).val > nodes.get(i + 1).val) {
        		index1 = i; i++; break;
        	}
        }
        for (; i < nodes.size() - 1; i++) {
        	if (nodes.get(i).val > nodes.get(i + 1).val) {
        		index2 = i + 1; break;
        	}
        }
        if (-1 == index1) return;
        if (-1 == index2) index2 = index1 + 1;   
        TreeNode r1 = nodes.get(index1);
        TreeNode r2 = nodes.get(index2);
        int val = r1.val;
        r1.val = r2.val;
        r2.val = val;
        nodes.clear();
        traversal(root, nodes);
        System.out.println();
        for (TreeNode tn : nodes) {System.out.print(tn.val + " ");}
    }