本文整理汇总了C++中BSTree::Height方法的典型用法代码示例。如果您正苦于以下问题:C++ BSTree::Height方法的具体用法?C++ BSTree::Height怎么用?C++ BSTree::Height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSTree
的用法示例。
在下文中一共展示了BSTree::Height方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,char*argv[])
{
AVLTree<string> avlTree;
BSTree<string> bsTree;
string str, last;
char c;
if (argc != 2)
{
cerr << "Parameters: <filename>. use quotations around long path names." << endl;
return 1;
}
ifstream ifsInput(argv[1],ios::in | ios::binary);
if (!ifsInput)
{
cerr << "Couldn't open input file." << endl;
return 2;
}
while (ifsInput.get(c) && !ifsInput.eof())
{
switch (c)
{
case '.':
case ',':
case '\'':
case '\"':
case ':':
case ';':
case '<':
case '>':
case '/':
case '?':
case '[':
case ']':
case '{':
case '}':
case '\\':
case '|':
case '!':
case '#':
case '$':
case '%':
case '^':
case '&':
case '*':
case '(':
case ')':
case '_':
case '=':
case '`':
case ' ':
case '\r':
case '\n':
case '\t':
if (str.size())
{
avlTree.Insert(str);
bsTree.Insert(str);
last = str;
}
str = "";
continue;
default:
str += c;
continue;
}
}
ifsInput.close();
//x.Output(Print);
cout << "AVL Height: " << avlTree.Height() << endl;
cout << "BST Height: " << bsTree.Height() << endl;
cout << "AVL Size: " << avlTree.Size() << endl;
cout << "BST Size: " << bsTree.Size() << endl;
clock_t stime, etime;
double elapse;
int i;
cout << "Searching for \"" << last << "\"..." << endl;
stime = clock();
for (i = 0; i < 100000; i++)
avlTree.Find(last);
etime = clock();
elapse =(double)(etime-stime)/CLOCKS_PER_SEC;
cout << "Search in AVL tree took " << elapse << " seconds " << endl;
stime = clock();
for (i = 0; i < 100000; i++)
bsTree.Find(last);
etime = clock();
elapse =(double)(etime-stime)/CLOCKS_PER_SEC;
cout << "Search in BST tree took " << elapse << " seconds " << endl;
//.........这里部分代码省略.........