本文整理汇总了C++中BSTree::BSTreeTraverse方法的典型用法代码示例。如果您正苦于以下问题:C++ BSTree::BSTreeTraverse方法的具体用法?C++ BSTree::BSTreeTraverse怎么用?C++ BSTree::BSTreeTraverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSTree
的用法示例。
在下文中一共展示了BSTree::BSTreeTraverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BinarySearchTreeTest
void BinarySearchTreeTest(int nmbItems)
{
int i=0;
int value;
BSTree *BinarySearchTree = new BSTree();
while (i < nmbItems)
{
value = rand()%10; // Random integer value
cout << value;
if (i < (nmbItems-1))
cout << ", ";
BinarySearchTree->insert(value);
i++;
}
cout << endl;
cout << "Entered " << nmbItems << " random values into BSTree Data Structure ..." << endl;
cout << endl << "Preorder Traversal: ";
BinarySearchTree->BSTreeTraverse(PREORDER);
cout << endl << "Inorder Traversal: ";
BinarySearchTree->BSTreeTraverse(INORDER);
cout << endl << "Post order Traversal: ";
BinarySearchTree->BSTreeTraverse(POSTORDER);
cout << endl;
cout << "Search for a value in the tree: ";
cin >> value;
if (BinarySearchTree->find(value))
cout << "Found " << value;
else
cout << "Could not find " << value;
cout << endl;
BinarySearchTree->~BSTree();
}