题目:
输入一个函数,输入一个二叉树,该函数输出它的镜像
代码:
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); } } }