def bft(root_node):
    if root_node is None:
        return False

    result = []

    queue = Queue()

    queue.enqueue(root_node)

    while not queue.isEmpty():

        current_node = queue.dequeue()

        result.append(str(current_node.data))

        if current_node.left:

            queue.enqueue(current_node.left)

        if current_node.right:

            queue.enqueue(current_node.right)

    result_string = "->".join(result)

    print result_string
def bft(root_node):
    if root_node is None:
        return False

    result = []

    queue = Queue()

    queue.enqueue(root_node)

    while not queue.isEmpty():

        current_node = queue.dequeue()

        result.append(str(current_node.data))

        if current_node.left:

            queue.enqueue(current_node.left)

        if current_node.right:

            queue.enqueue(current_node.right)

    result_string = "->".join(result)

    print result_string
def print_out_tree(root_node):
    if root_node is None:
        return False

    result = []

    level = 0

    last_level = -1

    level_queue = Queue()

    queue = Queue()

    queue.enqueue(root_node)

    level_queue.enqueue(level)

    while not queue.isEmpty():

        current_node = queue.dequeue()

        current_level = level_queue.dequeue()

        # result.append(str(current_node.data))

        result.append(str(current_node.data))

        # print "%s" %(current_node.data)

        level += 1

        if current_node.left:

            queue.enqueue(current_node.left)

            level_queue.enqueue(level)

        if current_node.right:

            queue.enqueue(current_node.right)

            level_queue.enqueue(level)

        print "  ".join(result)

        if current_level is not last_level:

            result = []

            last_level = current_level
def print_out_tree(root_node):
    if root_node is None:
        return False

    result = []

    level = 0

    last_level = -1

    level_queue = Queue()

    queue = Queue()

    queue.enqueue(root_node)

    level_queue.enqueue(level)

    while not queue.isEmpty():

        current_node = queue.dequeue()

        current_level = level_queue.dequeue()

        # result.append(str(current_node.data))

        result.append(str(current_node.data))

        # print "%s" %(current_node.data)

        level += 1

        if current_node.left:

            queue.enqueue(current_node.left)

            level_queue.enqueue(level)

        if current_node.right:

            queue.enqueue(current_node.right)

            level_queue.enqueue(level)

        print "  ".join(result)

        if current_level is not last_level:

            result = []

            last_level = current_level