Tree insert: searchs for that element A[i]
Tree walk:
Theorem:
E[height of a randomly built binary search tree] = O(lg n)
Proof outline
- Prove Jensen's inequality:
for convex function f - Instead of analyzing = the random variable of the height of a randomly constructed BST on n nodes, we analize
- Prove that
- Conclude that
(by Luke Devroy, 1986)
Proof 1.Jensen's inequality
is convex if for all and all with ,
Lemma
if is convex & & & ,
then
Induction
Base Case: When n = 1,
Induction Step:
Jensen's inequality
(f is a convex and X is a integer random variable)
proof:
Proof 2. Analysis Yn
Xn = the random variable of the height of a randomly constructed BST on n nodes. Yn = 2 Xn
If root r has rank k, then Xn = 1 + max{Xk-1, Xn-k}, Yn = 2 * max{Yk-1, Yn-k}
define indicator r.v.'s
Pr{Znk = 1} = E[Znk] = 1/n
Proof 3. Analysis E[Yn]
Then, we are going to use substitution.
Claim:
Proof:
The base case must be true when c is sufficiently large.
Induction Step:
Proof 4.
(簡單地使用了Jensen's inequality)
( lg(O(n3)) = lg(cn3) = 3lg(n) + lg(c) )