Exemplo n.º 1
0
int main() {
	IntBinaryTree tree;
	cout << "Inserting the numbers 5, 8, 3, 12, 9, 1"
		", 1000, 3, 500.\n\n";
	tree.insert(5);
	tree.insert(8);
	tree.insert(3);
	tree.insert(12);
	tree.insert(9);
	tree.insert(1);
	tree.insert(1000);
	tree.insert(3);
	tree.insert(500);

	tree.plusOne();

	cout << "Inorder traversal: ";
	tree.showInOrder();

	cout << "\n\nPreorder traversal: ";
	tree.showPreOrder();

	cout << "\n\nPostorder traversal: ";
	tree.showPostOrder();

	cout << "\n\nLargest is: " << tree.large();

	if(tree.search(3)) {
		cout << "\n\n3 is found in the tree.\n";
	}
	else
		cout << "\n\n3 was not found in the tree.\n";

	cout << "\nDeleting 8...\n";
	tree.remove(8);
	cout << "\nDeleting 12...\n";
	tree.remove(12);
	cout << "Now, here are the nodes:\n";
	tree.showInOrder();
	cout << endl;
    
    return 0;
}
Exemplo n.º 2
0
int main()
{
	IntBinaryTree tree;

	cout << "Inserting the numbers 5 8 3 12 9.";
	tree.insert(5);
	tree.insert(8);
	tree.insert(3);
	tree.insert(12);
	tree.insert(9);

	cout << "\nHere are the values in the tree:\n";
	tree.showInOrder();

	cout << "\nDeleting 8...\n";
	tree.remove(8);

	cout << "Deleting 12...\n";
	tree.remove(12);

	cout << "Now, here are the nodes:\n";
	tree.showInOrder();
	return 0;
}