请教一个二叉树的程序

来源:百度知道 编辑:UC知道 时间:2024/06/08 18:40:19
请教一个编程的问题,要求是有一系列数据,要求插入到树中,再已知一个key,搜索是否在树里面,这样一个程序要怎么写啊,麻烦高手过来帮帮忙,呵呵,谢谢了~~~~~~~~~~~~

#ifndef BINARYTREE_H
#define BINARYTREE_H

#include <iostream>
#include <vector>

using std::vector;
using std::ostream;
using std::cout;

#define NDEBUG

#ifndef NDEBUG
#define TRACE(os, m) os << m
#else
#define TRACE(os, m)
#endif

template <typename T>
class BinaryTree {
public:
BinaryTree();
BinaryTree(const BinaryTree &tree);
public:
enum PrintType {INORDER, PREORDER, POSTORDER};
typedef typename vector<T>::size_type size_type;
public:
void insert(const T &elem);
T *find(const T &elem) const;
void clear();
void print(ostream &os, PrintType pt) const;
size_type size() const;

BinaryTree &operator=(BinaryTree &tree);
private:
class _Node {
public:
_Node();
_Node(const T &elem);
T _elem;