本文整理汇总了C++中BSTree::PreOrderTraversal方法的典型用法代码示例。如果您正苦于以下问题:C++ BSTree::PreOrderTraversal方法的具体用法?C++ BSTree::PreOrderTraversal怎么用?C++ BSTree::PreOrderTraversal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSTree
的用法示例。
在下文中一共展示了BSTree::PreOrderTraversal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
cout <<"Insert data into BSTree"<<endl;
mix(recs,recs_read);
mix(keys,recs_read);
for ( unsigned i=0; i<recs_read; i++ )
{
bst.Insert(recs[i]);
}
cout << "Done: Insert" << endl
<<"*************************"<<endl
<<"Test: Depth"<<endl;
unsigned bd = bst.Depth();
const unsigned CD = 46;
if ( Final_Test && bd != CD )
{
cout << "bst depth: " << bst.Depth() << endl;
cout << "Correct Depth: " << CD<<endl
<<"<enter> to continue"<<endl;
cin.get();
}
cout << "Done: Depth"<<endl
<<"*************************"<<endl
<<"Test: Traversals"<<endl;
least = recs_inorder[least_rec];
pcnt = 0;
bst.InOrderTraversal(Inord);
cout << " Done: In order traversal #1"<<endl;
ord_cnt = 0;
bst.PreOrderTraversal(Preord);
cout << " Done: Pre order traversal #1"<<endl;
ord_cnt = 0;
bst.PostOrderTraversal(Postord);
cout << " Done: Post order traversal #1"<<endl
<<"Done: Traversals"<<endl
<<"*************************"<<endl
<<"Test: Find"<<endl;
for ( unsigned i=0; i<recs_read; i++ )
{
Record ret = bst.Find(keys[i]);
if ( ret.Key() != keys[i] )
{
cout <<i<< " Find Error. You found the Record with key: "
<< ret.Key() <<endl<< " when searching for key: "
<< keys[i] << endl
<<"<enter> to continue"<<endl;
cin.get();
}
}
cout << "Done: Find"<<endl
<<"*************************"<<endl
<<"Test: Find bad key"<<endl;
KeyType bad_key("~badkey"); //to the right
Record BK = bst.Find(bad_key);
KeyType KNF("KEY NOT FOUND");
if ( BK.Key() != KNF )