Give an asymptotic upper bound for the height of the n-node binary search tree in which the average depth of a node is Θ (log n)

Recently, I am trying to solve all the exercises in CLRS. but some of them I can’t understand. Here is one of them, from exercise CLRS 12.4-2:

Describe the binary search tree on n nodes, so that the average depth of a node in the tree is Θ (log n), but the height of the tree is ω (log n). Give the asymptotic upper bound of the height of the search tree of the binary tree n-node, in which the average depth of a node is Θ (log n).

Can anyone share some ideas or links to solve this problem? Thank.

+5
source share
3 answers

, , : n , f (n) . , , , n - f (n) - 1 , f (n). f (n) .

, ? , n , n - f (n) - 1 , , 2 ^ k - 1. 1 * 2 + 2 * 3 + 4 * 4 + 8 * 5 +... + 2 ^ (k-1) * k, (IIRC) k 2 ^ k, (n - f (n)) log (n - f (n)) k. f (n) ^ 2. , ((n - f (n)) log (n - f (n)) + f (n) ^ 2)/n. , f (n). f (n), O (log n).

f (n),

  • n - f (n) = & Theta; (n), , ,
  • f (n) ^ 2/n = O (log n), .

f (n) = & Theta; (sqrt (n log n)), , 1 2 . ( ), , . & Theta; (sqrt (n log n)), & ​​Theta; (Log n).

, ! , , . , .: -)

+6

. ( , node node, ).

. (, ).

, . . . ( , , ). , . (, ).

0

, , "" , . k height = lg k, 0 < k < n, "" n-k , . lg k + n - k.

. [j * 2 ^ j], j = 0 j = lg k. 2k lg k.

, [i + lg k], = 0 = n-k. (n-k) lg k + (1/2) (n-k) ^ 2.

, n, (1 + k/n) lg k + (n-k) ^ 2/(2n). , 0 < k < n, O (lg n) , k . , , O (lg n). , (n-k) ^ 2 = O (n lg n), k = n - O (sqrt (n lg n)).

lg k + n - k = O (sqrt (n lg n))

it is asymptotically larger than usual O (log n) and is asymptotically the highest, you can make a tree, while maintaining the average depth O (log n)

0
source

All Articles