BST Sort

Computer Science Level pending

While playing with Binary Search Trees , you discover the following sorting algorithm. Given an unsorted array of n 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?

O ( n 2 ) O(n^2) O ( n log n ) O(n\log n ) O ( n ) O(n) O ( log n ) O( \log n )

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

1 pending report

Vote up reports you agree with

×

Problem Loading...

Note Loading...

Set Loading...