当前位置: 首页>>代码示例>>C++>>正文


C++ BinaryTree::InsertNode方法代码示例

本文整理汇总了C++中BinaryTree::InsertNode方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryTree::InsertNode方法的具体用法?C++ BinaryTree::InsertNode怎么用?C++ BinaryTree::InsertNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BinaryTree的用法示例。


在下文中一共展示了BinaryTree::InsertNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createBinaryTree

BinaryTree* createBinaryTree()
{
    BinaryTree* root = new BinaryTree(50);
    
    root->InsertNode(10);
    root->InsertNode(5);
    root->InsertNode(20);
    root->InsertNode(8);
 /*   root->InsertNode(100);
    root->InsertNode(40);
    root->InsertNode(6);
    root->InsertNode(4);
    root->InsertNode(70);*/
    
    return root;
    
}
开发者ID:RashmiDR,项目名称:Craftsmanship,代码行数:17,代码来源:main.cpp

示例2: main

/************************************* MAIN FUNCTION *************************************/
int main()
{
  //#7 Create a binary tree call b and insert nodes m,a,q
  //Create a binary tree called 'b'
  BinaryTree * b = new BinaryTree();
  char m = 'm', a = 'a', q = 'q';
  //insertNodes 'm','a','q' in this specific order
  b->InsertNode(m);
  b->InsertNode(a);
  b->InsertNode(q);
  //#8 call recurisve and non recursive functions of order types
  //call both postorderR and postorder
  std::cout << "Postorder: ";
  b->Postorder();
  std::cout << std::endl;
  std::cout << "PostorderR: ";
  b->PostorderR(b->GetRoot());
  std::cout << std::endl;

  //call both inorderR and inorder
  std::cout << "Inorder: ";
  b->Inorder();
  std::cout << std::endl;
  std::cout << "InorderR: ";
  b->InorderR(b->GetRoot());
  std::cout << std::endl;

  //call both preorderR and preorder
  std::cout << "Preorder: ";
  b->Preorder();
  std::cout << std::endl;
  std::cout << "PreorderR: ";
  b->PreorderR(b->GetRoot());
  std::cout << std::endl;
  std::system("pause");
  return 1;
}
开发者ID:Rhernandez513,项目名称:Comp-271-work,代码行数:38,代码来源:lab5.cpp

示例3: main

int main() {
	BinaryTree* tree = new BinaryTree();
	tree->InsertNode("A");
	tree->InsertNode("B");
	tree->InsertNode("C");
	tree->InsertNode("D");
	tree->InsertNode("E");
	tree->InsertNode("F");
	tree->InsertNode("G");
	tree->InsertNode("H");
	tree->InsertNode("I");
	tree->InsertNode("J");
	tree->InsertNode("K");
	tree->InsertNode("L");

	


	cout << "Pre order traversal" << endl;
	tree->PreOrder(tree->root);
	cout << endl;


	cout << "In order traversal" << endl;
	tree->InOrder(tree->root);
	cout << endl;

	cout << "Post order traversal" << endl;
	tree->PostOrder(tree->root);
	cout << endl;

	cin.get();
	return 0;

	

}
开发者ID:ptang0917,项目名称:COP3530-Projects,代码行数:37,代码来源:COP3530Assignment4.cpp


注:本文中的BinaryTree::InsertNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。