Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVL Tree Rotation Efficiency

Tags:

big-o

avl-tree

What is the Big O efficiency of the AVL tree rotation specifically?

For example when inserting: - O(logN) to search for the position - O(1) to insert - ? for balancing (if it needs to be re-balanced)

I thought it would be O(logN) but I found a site which claims it's O(1) - unless I have misread it - http://users.informatik.uni-halle.de/~jopsi/dinf504/chap4.shtml

(Would this also be the same for a 2-3 tree?)

Thanks for the help in advance

like image 717
GJHix Avatar asked Dec 06 '25 08:12

GJHix


1 Answers

The complexity is O(log n) as you say. I believe that in the article they mean constant time for each rebalancing operation i.e. each rotation, while you have to do O(log n) rotations. Whatever the truth the complexity is as you say logarithmic.

like image 195
Ivaylo Strandjev Avatar answered Dec 08 '25 01:12

Ivaylo Strandjev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!