• retagged by
798 views

1 Answer

Best answer
3 3 votes

To create an AVL tree , we have to insert n elements into it.And we know that cost of insertion in a balanced tree = O(logn)

Therefore total complexity = O(nlogn)

To be more accurate mathematically , 

No. of operations involved = log1 + log2 + log3 ..+logk ...+ logn [ Since for balanced tree of k nodes , cost of insertion = O(logk)]

                                      = log (1.2.3....n)

                                      = log n!

By Stirling's approximation , we know

log n! = O(nlogn)

Therefore , the complexity of building an AVL tree is O(nlogn)

For reference, you may visit :

http://stackoverflow.com/questions/17629668/difference-between-the-time-complexity-required-to-build-binary-search-tree-and

• selected by
Position:
Show:

Related questions

10 10 votes
1 1 answer
550
550 views
6 6 votes
1 1 answer
298
298 views
7 7 votes
1 1 answer
225
225 views
GO Classes asked Jul 24
225 views
Insertion of a new element into an AVL tree may violate the AVL balance condition. Usually, we perform a rotation at the first node on the path from the inserted element ...
6 6 votes
1 1 answer
234
234 views
GO Classes asked Jul 23
234 views
For the following three trees, choose the correct classification.Tree (a):Tree (b):Tree (c):Which option is correct?All three are valid AVL trees. Tree (a) is not a valid...