BST Sort

Computer Science Level pending

While playing with Binary Search Trees, you discover the following sorting algorithm. Given an unsorted array of \(n\) distinct numbers, you begin by iterating through it and insert each value to a Binary Search Tree. You then call the recursive procedure shown below on the tree.

1
2
3
4
5
def sort_tree(node):
    if node is not None:
        sort_tree(node.left)
        print node.value
        sort_tree(node.right)

It prints out the array in sorted order. What is the run-time of this sorting algorithm?

×

Problem Loading...

Note Loading...

Set Loading...