Esempio n. 1
0
int main()
{
   IntBinaryTree tree;

   // Insert some nodes.
   cout << "Inserting nodes.\n";
   tree.insertNode(5);
   tree.insertNode(8);
   tree.insertNode(3);
   tree.insertNode(12);
   tree.insertNode(9);

   // Display inorder.
   cout << "Inorder traversal:\n";
   tree.displayInOrder();

   // Display preorder.
   cout << "\nPreorder traversal:\n";
   tree.displayPreOrder();

   // Display postorder.
   cout << "\nPostorder traversal:\n";
   tree.displayPostOrder();
   return 0;
}
Esempio n. 2
0
int main()
{
   IntBinaryTree tree;

   // Insert some nodes in the tree.
   cout << "Inserting nodes.\n";
   tree.insertNode(5);
   tree.insertNode(8);
   tree.insertNode(3);
   tree.insertNode(12);
   tree.insertNode(9);

   // Search for the value 3.
   if (tree.searchNode(3))
      cout << "3 is found in the tree.\n";
   else
      cout << "3 was not found in the tree.\n";

   // Search for the value 100.
   if (tree.searchNode(100))
      cout << "100 is found in the tree.\n";
   else
      cout << "100 was not found in the tree.\n";
   return 0;
}