<剑指offer> 第16题

题目:

输入一个函数,输入一个二叉树,该函数输出它的镜像

代码:

public class Sixteenth {
  
public static class BinaryTreeNode{
        BinaryTreeNode leftChild;
        BinaryTreeNode rightChild;
        int val;
    }
    public static void getMirrorBinaryTree(BinaryTreeNode node){
        if(node != null){
            BinaryTreeNode temp = node.leftChild;
            node.leftChild = node.rightChild;
            node.rightChild = temp;

            getMirrorBinaryTree(node.leftChild);
            getMirrorBinaryTree(node.rightChild);
        }
    }

}
原文地址:https://www.cnblogs.com/HarSong13/p/11330480.html