#!/usr/local/cpython-3.7/bin/python3

"""Test a large binary tree, to see if the stack overflows."""

import random

import bst


def main():
    """Test."""
    nums = 10_000_000
    divisor = 10_000
    nums_mult = nums * 1000

    random.seed(0)

    # create the large tree
    binary_tree = bst.Node()
    for i in range(1, nums + 1):
        if i % divisor == 0:
            print('adding {:,}th number'.format(i))
        binary_tree.insert(random.randint(0, nums_mult))

    # This is "yield from" recursion - it's a little different.
    for elno, element in enumerate(binary_tree()):
        if elno % divisor == 0:
            print('{:,}'.format(element))

    # This is straightforward recursion
    print('count of nodes in tree is {:,}'.format(len(binary_tree)))
    print('depth of tree is {:,}'.format(binary_tree.depth()))


main()