设为首页 加入收藏

TOP

计算机二级辅导:二叉树的C++描述
2014-11-18 13:50:55 】 浏览:8076
Tags:计算机 二级 辅导 描述

  /*对二叉树的操作主要通过递归实现,递归能把一个复杂的问题最大程度的简化。以前实现二叉树主要通过C语言实现的,现在正在学习CORE C++,故决定用C++重新实现...*/


  #ifndef _TREE_H_


  #define _TREE_H_


  #include


  using namespace std;


  template class Tree //binary sort tree


  {


  struct Node


  {


  T data;


  Node *left;


  Node *right;


  };


  Node *root;


  public:


  Tree():root(NULL){};


  void add(T value)//add element to tree


  {


  Node *n = new Node;


  n->data = value;


  n->left = NULL;


  n->right = NULL;


  insert(root,n);


  }


  void show(){ preShow(root); cout<


  void sortShow(){ midShow(root); cout<


  void clear(){ clearTree(root);};//clear the tree


  int count(){//calculate the node's count of tree


  return count(root);


  }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇理解C++编译器编译模板类的过程 下一篇新手入门:C/C++中的结构体(struc..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目