?? testprogbinarysearchtree.cpp
字號:
#include <iostream>
#include "binarySearchTree.h"
using namespace std;
int main()
{
bSearchTreeType<int> treeRoot;
int num;
cout << "Enter numbers ending with -999." << endl;
cin >> num;
while (num != -999)
{
treeRoot.insert(num);
cin >> num;
}
cout << endl << "Tree nodes in inorder sequence: ";
treeRoot.inorderTraversal();
cout << endl << "Tree nodes in preorder sequence: ";
treeRoot.preorderTraversal();
cout << endl << "Tree nodes in postorder sequence: ";
treeRoot.postorderTraversal();
cout << endl;
cout << "Tree Height: " << treeRoot.treeHeight()
<< endl;
cout << "Number of Nodes: "
<< treeRoot.treeNodeCount() << endl;
cout << "Number or Leaves: "
<< treeRoot.treeLeavesCount() << endl;
cout << endl;
cout << "Enter the item to be searched: ";
cin >> num;
cout << endl;
if (treeRoot.search(num))
cout << num << " is in the binary tree." << endl;
else
cout << num << " is not in the tree." << endl;
cout << "Enter the item to be deleted: ";
cin >> num;
cout << endl;
treeRoot.deleteNode(num);
cout << endl << "**** After the delete operation.****"
<< endl;
cout << "Tree nodes in inorder sequence: ";
treeRoot.inorderTraversal();
cout << endl << "Tree nodes in preorder sequence: ";
treeRoot.preorderTraversal();
cout << endl << "Tree nodes in postorder sequence: ";
treeRoot.postorderTraversal();
cout << endl;
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -