二叉树的镜像 :
镜像即就是在镜子中所成的像
代码实现:
PS:搜索二叉树和普通二叉树实现方法是相同的,只是两种建树过程有所不同,此处实现的是搜索二叉树。
1.递归实现:
#pragma once
#include <iostream>
#include <Windows.h>
#include <assert.h>
using namespace std;
template <class K>
struct SearchBinaryTreeNode
{
K _key;
SearchBinaryTreeNode<K>* _left;
SearchBinaryTreeNode<K>* _right;
SearchBinaryTreeNode(const K& key)
:_key(key)
, _left(NULL)
, _right(NULL)
{}
};
template <class K>
class SearchBinaryTree
{
typedef SearchBinaryTreeNode<K> Node;
public:
SearchBinaryTree()
:_r