# 74. 二叉树的镜像

java

```java
package offer;

import leetcode.common.TreeNode;
import leetcode.common.TreeUtils;

/**
 * 二叉树的镜像
 *
 * 操作给定的二叉树，将其变换为源二叉树的镜像。
 * 输入描述:
 * 二叉树的镜像定义：源二叉树
 *             8
 *            /  \
 *           6   10
 *          / \  / \
 *         5  7 9 11
 *
 *         镜像二叉树
 *             8
 *            /  \
 *           10   6
 *          / \  / \
 *         11 9 7  5
 *
 */
public class MirrorSolution {
    public void Mirror(TreeNode root) {
        if(root!=null){
            TreeNode tmp=root.left;
            root.left=root.right;
            root.right=tmp;
            Mirror(root.left);
            Mirror(root.right);
        }
    }

    public static void main(String[] args){
        String str="8,6,5,#,#,7,#,#,10,9,#,#,11,#,#";
        TreeNode root=TreeUtils.stringToTreeWith(str,",");
        new MirrorSolution().Mirror(root);
        TreeUtils.travser(root);
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://im-qianuxn.gitbook.io/pytorch/ji-suan-ji/shua-ti/shu-ju-jie-gou-lei/74-er-cha-shu-jing-xiang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
