Data structures 向空AVL树中添加N个元素的运行时间

Data structures 向空AVL树中添加N个元素的运行时间,data-structures,time-complexity,avl-tree,Data Structures,Time Complexity,Avl Tree,“高度h中avl树的最小节点数”的公式是递归的: n(0)=1,n(1)=2 n(h)=1+n(h-1)+n(h-2) 另一方面,我在互联网上发现了这一点,用于解释向空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 ri

“高度h中avl树的最小节点数”的公式是递归的: n(0)=1,n(1)=2 n(h)=1+n(h-1)+n(h-2)

另一方面,我在互联网上发现了这一点,用于解释向空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个元素,那么对于不同的运行是否有更好的运行时间?或者我可以说,从advanced知道每个元素将添加到哪里,所以运行时间是有限的

更简单的上限解释

如果有n个元素,则一次插入所需的最多时间是log(n)time。如果我们假设所有n项的插入时间都是最坏的情况,那么您将得到
O(n*log(n))
,而不需要复杂的解释

另一种看法是:

日志(1)+日志(2)+日志(3)+…+log(n)