「高さhのavlツリーの最小ノード」の式は、再帰的です。 n(0)= 1、n(1)= 2 n(h) = 1 + N(H-1)+ N(H-2)一方空のAVLツリーにN個の要素を追加する実行時間
は、iが空のAVLツリーにN個の要素を追加することの複雑さを説明するためのインターネットでこれを見つけた:
Well, imagine the tree being built.
One by one, the elements go through the tree nodes, and chose their abode by taking either a left or a right. The tree balances itself every time the heights are too skewed.
Of course, the cost of balancing the tree is an O(1) operation, so I do not consider that in the complexity analysis.
Complexity: log(1)+log(2)+log(3)+....+log(n)
=log(n!)
=O(nlogn-n+O(log(n)))
=O(nlogn)
しかし、ここでは分かりませんが、高さが増加する要素を追加するたびに計算ログ(n!)が表示されないのはなぜですか?提示された再帰式は、大きなNの場合、多くの要素の後でのみavlの高さが増加するので、漸近的にlog(n!
さらに悪いケースは何ですか?このような複雑な状況では、より悪いケースと最善のケースがありますか?たとえば、特定のN要素が追加されているとします。異なる実行の実行時間が改善される可能性がありますか?それとも、各要素が追加される予定なので、実行時間が厳密に制限されているということは、高度からわかっていると言えますか?