#include <iostream>
#include <stdexcept>
#include "binary_search_tree.h"

int main() {
    BinarySearchTree<int> tree;
    tree.remove(123987);
    try {
        tree.find_max();
    } catch (std::exception& e) {
        std::cerr << e.what() << "\n";
    }
    try {
        tree.find_min();
    } catch (std::exception& e) {
        std::cerr << e.what() << "\n";
    }
    int n = 120;
    while (n != 1) {
        tree.insert(n);
        if (n % 2 == 0)
            n = n / 2;
        else
            n = 3 * n + 1;
    }
    tree.insert(2);
    tree.remove(2);
    tree.remove(18);
    tree.print_tree(std::cout);
    std::cout << tree.find_max() << "\n";
    BinarySearchTree<int> tree2;
    tree2 = tree;
    tree.remove(6);
    std::cout << tree.root_data() << "\n";
    std::cout << "contains 9? " << std::boolalpha << tree.contains(9) << "\n";
    tree2.insert(9);
    std::cout << tree2.find_max() << "\n";
    std::cout << tree2.root_data() << "\n";
    tree2.remove(7);
    BinarySearchTree<int> tree3(tree);
    tree3 = tree3;
    tree3.~BinarySearchTree();
    tree3.print_tree();
}