本文整理汇总了C++中BinaryTree::in_order方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryTree::in_order方法的具体用法?C++ BinaryTree::in_order怎么用?C++ BinaryTree::in_order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryTree
的用法示例。
在下文中一共展示了BinaryTree::in_order方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
char anyKey;
cout<<"Arboles Binarios"<<endl;
BinaryTree<TreeTraits> btMyTree;
btMyTree.insert(33);
btMyTree.insert(23);
btMyTree.insert(41);
btMyTree.insert(11);
btMyTree.insert(27);
btMyTree.insert(37);
btMyTree.insert(51);
cout<<"InOrder"<<endl;
btMyTree.in_order(btMyTree.root);
cout<<"PreOrder"<<endl;
btMyTree.pre_order(btMyTree.root);
cout<<"PostOrder"<<endl;
btMyTree.post_order(btMyTree.root);
cout<<"Wait any key ..."<<endl;
cin>>anyKey;
return 0;
};
示例2: main
int main()
{
BinaryTree<char> t;
Node<char> *a = t.makeTree('A', NULL, NULL);
Node<char> *b = t.makeTree('B', NULL, NULL);
Node<char> *c = t.makeTree('C', a, b);
Node<char> *d = t.makeTree('D', NULL, NULL);
Node<char> *e = t.makeTree('E', c, d);
Node<char> *f = t.makeTree('F', NULL, e);
t.pre_order();
cout << endl;
t.in_order();
cout << endl;
t.post_order();
cout << endl;
cout << t.get_nodenum() << endl;
cout << t.get_height() << endl;
return 0;
}
示例3: main
/* usage: ./proj5 organisms.txt
* *******************************************
* Given a correct file the program takes a list of organisms and
* constructs its ancestral tree based on the scores in the file.
* The only output is the string parenthetical expression which
* represents the closest organisms joined in a tuple of the form
* ((dog,wolf),mountianGoat)
*
*/
int main(int argc, char* argv[]){
std::string addressFile="";
/*
* If the program is ran without sufficient arguments it Will exit gracefully
* with suggestions for the usage of the program.
*/
if (argc < 2) {
std::cerr << "Address File not Found\n";
std::cerr << "Usage: " << argv[0] << " adresses.txt" << std::endl;
return -1;
}
addressFile=argv[1];
std::ifstream inFile;
inFile.open(addressFile.c_str()); // need to open the fileargv[1].c_str()
if(!inFile){
write_Log( "Valid File not found: ** Exiting ** ");
exit(1);
}
std::list< BinaryTree<Organism*> *> treeList;
/****************************************
* Build a vector of Organisms from the file
***********************************************/
try {
std::string str;
std::vector<std::string> data;
while(std::getline(inFile, str, '\n')) {
try{
data = split(str);
}catch(...){
write_Log("**********Exception Throw splitting string: Line Skipped********");
write_Log("Error Occured IN: "+str);
continue;
}
//double score = std::stod (data[1]);
Organism * toAdd = new Organism(data[0], atoi(data[1].c_str()));
//Organism * toAdd = new Organism(data[0], score);
BinaryTree<Organism*> * tree = new BinaryTree<Organism*> (toAdd);
treeList.push_front(tree);
}
} catch(...){
write_Log( "*********Exception thrown building Binary Trees: *********");
write_Log("*********Please correct Invalid Input: ********************");
}
/********************************************
*Initial List of Binary Trees Built
*******************************************/
//write_Log("Length of list of trees = "+convertDigit(treeList.size()));
/*******************************************************************
* Build LifeTree:
* *****************************************************************
*/
BinaryTree<Organism*> orgTree;
buildOrgTree(treeList,orgTree);
/*
*DISPLAY THE FINAL TREES ROOT NODE
*/
orgTree.in_order(display);
write_Log("orgTree has heigh = " + convertDigit(orgTree.height()));
write_Log(orgTree.get_root()->toString());
return 0;
}