<剑指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);
        }
    }

}

 

posted @ 2019-08-10 08:57  HarSong13  阅读(136)  评论(0编辑  收藏  举报