⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binary.cpp

📁 data structures, algorithms and Application书的源代码
💻 CPP
字号:
// test binary tree class

#include <iostream.h>
#include "binary.h"

// globals
int count = 0;
BinaryTree<int> a,x,y,z;

template<class T>
void ct(BinaryTreeNode<T> *t) {count++;}

void main(void)
{
   y.MakeTree(1,a,a);
   z.MakeTree(2,a,a);
   x.MakeTree(3,y,z);
   y.MakeTree(4,x,a);
   cout << "Preorder sequence is ";
   y.PreOutput();
   cout << "Inorder sequence is ";
   y.InOutput();
   cout << "Postorder sequence is ";
   y.PostOutput();
   cout << "Level order sequence is ";
   y.LevelOutput();
   cout << "Number of nodes = ";
   cout << y.Size() << endl;
   cout << "Height = ";
   cout << y.Height() << endl;
   y.PreOrder(ct);
   cout << "Count of nodes is " << count << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -