



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




If you hold a cat by the tail you learn things you cannot learn any other way. — Mark Twain
The simple recursive structure of skip lists made it relatively easy to derive an upper bound on the expected worst-case search time, by way of a stronger high-probability upper bound on the worst-case search time. We can prove similar results for treaps, but because of the more complex recursive structure, we need slightly more sophisticated probabilistic tools. These tools are usually called tail inequalities ; intuitively, they bound the probability that a random variable with a bell-shaped distribution takes a value in the tails of the distribution, far away from the mean. The simplest such bound is called Markov’s Inequality.
Markov’s Inequality. Let X be a non-negative integer random variable. For any t > 0 , we have Pr[ X ≥ t ] ≤ E[ X ] /t.
Proof: This follows from the definition of expectation by simple algebraic manipulation.
k = 0
k · Pr[ X = k ] [definition of E[ X ]]
k = 0
Pr[ X ≥ k ] [algebra]
∑^ t −^1
k = 0
Pr[ X ≥ k ] [since t < ∞]
∑^ t −^1
k = 0
Pr[ X ≥ t ] [since k < t ]
= t · Pr[ X ≥ t ] [algebra] É
Unfortunately, the bounds that Markov’s inequality implies (at least directly) are often very weak, even useless. (For example, Markov’s inequality implies that with high probability, every node in an n -node treap has depth O ( n^2 log n ). Well, duh! ) To get stronger bounds, we need to exploit some additional structure in our random variables. Recall that random variables X 1 , X 2 ,... , Xn are mutually independent if and only if
Pr
∧^ n
i = 1
( Xi = xi )
∏^ n
i = 1
Pr[ Xi = xi ]
for all possible values x 1 , x 2 ,... , xn. For examples, different flips of the same fair coin are mutually independent, but the number of heads and the number of tails in a sequence of n coin flips are not
independent (since they must add to n ). Mutual independence of the Xi ’s implies that the expectation of the product of the Xi ’s is equal to the product of the expectations:
∏^ n
i = 1
Xi
∏^ n
i = 1
E[ Xi ].
Moreover, if X 1 , X 2 ,... , Xn are independent, then for any function f , the random variables f ( X 1 ), f ( X 2 ),... , f ( Xn ) are also mutually independent. Suppose X =
∑ n i = 1 Xi^ is the sum of^ n^ mutually independent random^ indicator^ variables^ Xi^. For each i , let pi = Pr[ Xi = 1 ], and let μ = E[ X ] =
i E[ Xi^ ] =^
i pi^.
Chernoff Bound (Upper Tail). Pr[ X > ( 1 + δ ) μ ] <
eδ ( 1 + δ )^1 + δ
å μ for any δ > 0.
Proof: The proof is fairly long, but it replies on just a few basic components: a clever substitution, Markov’s inequality, the independence of the Xi ’s, The World’s Most Useful Inequality ex^ > 1 + x , a tiny bit of calculus, and lots of high-school algebra. We start by introducing a variable t , whose role will become clear shortly.
P r [ X > ( 1 + δ ) μ ] = Pr[ et X^ > et (^1 + δ ) μ ]
To cut down on the superscripts, I’ll usually write exp( x ) instead of ex^ in the rest of the proof. Now apply Markov’s inequality to the right side of this equation:
P r [ X > ( 1 + δ ) μ ] <
E[exp( t X )] exp( t ( 1 + δ ) μ )
We can simplify the expectation on the right using the fact that the terms Xi are independent.
E[exp( t X )] = E
exp
t
i
Xi
i
exp( t Xi )
i
E[exp( t Xi )]
We can bound the individual expectations E
î et Xi
ó using The World’s Most Useful Inequality:
E[exp( t Xi )] = pi et^ + ( 1 − pi ) = 1 + ( et^ − 1 ) pi < exp
( et^ − 1 ) pi
This inequality gives us a simple upper bound for E[ et X^ ]:
E[exp( t X )] <
i
exp(( et^ − 1 ) pi ) < exp
i
( et^ − 1 ) pi
= exp(( et^ − 1 ) μ )
Substituting this back into our original fraction from Markov’s inequality, we obtain
P r [ X > ( 1 + δ ) μ ] <
E[exp( t X )] exp( t ( 1 + δ ) μ )
exp(( et^ − 1 ) μ ) exp( t ( 1 + δ ) μ )
exp( et^ − 1 − t ( 1 + δ ))
μ
Notice that this last inequality holds for all possible values of t. To obtain the final tail bound, we will choose t to make this bound as tight as possible. To minimize et^ − 1 − t − tδ , we take its derivative with respect to t and set it to zero:
d d t ( et^ − 1 − t ( 1 + δ )) = et^ − 1 − δ = 0.
Now recall that An 1 = 1 if and only if node n has the smallest priority, and the other n − 2 indicator variables Ai 1 depend only on the order of the priorities of nodes 1 through n −1. There are exactly ( n − 1 )! permutations of the n priorities in which the n th priority is smallest, and each of these permutations is equally likely. Thus,
Pr
n ∧− 1
i = 2
( Aik = xi ) An 1 = xn
(^) = Pr
n ∧− 1
i = 2
( Aik = xi )
The inductive hypothesis implies that the variables A^21 ,... , An 1 − 1 are mutually independent, so
Pr
n ∧− 1
i = 2
( Aik = xi )
n ∏− 1
i = 2
Pr
î Ai 1 = xi
ó .
We conclude that
Pr
∧^ n
i = 2
( Ai 1 = xi )
(^) = Pr An 1 = xn^ ^ ·
n ∏− 1
i = 2
Pr
î Ai 1 = xi
n ∏− 1
i = 1
Pr
î Ai 1 = xi
ó ,
or in other words, that the indicator variables are mutually independent. É
Theorem 2. The depth of a randomized treap with n nodes is O (log n ) with high probability.
Proof: First let’s bound the probability that the depth of node k is at most 8 ln n. There’s nothing special about the constant 8 here; I’m being generous to make the analysis easier. The depth is a sum of n indicator variables Aik , as i ranges from 1 to n. Our Observation allows us to partition these variables into two mutually independent subsets. Let d< ( k ) =
i ( k ) =
i ( k ). If^ depth ( k )^ >^^8 ln^ n , then either^ d< ( k )^ >^^4 ln^ n^ or d> ( k ) > 4 ln n. Chernoff’s inequality, with μ = E[ d< ( k )] = Hk − 1 < ln n and δ = 3, bounds the probability that d< ( k ) > 4 ln n as follows.
Pr[ d< ( k ) > 4 ln n ] < Pr[ d< ( k ) > 4 μ ] <
e^3 44
å μ <
e^3 44
åln n = n ln( e
(^3) / 44 ) = n^3 −4 ln 4^ <
n^2
(The last step uses the fact that 4 ln 4 ≈ 5. 54518 > 5.) The same analysis implies that Pr[ d> ( k ) > 4 ln n ] < 1 /n^2. These inequalities imply the crude bound Pr[ depth ( k ) > 4 ln n ] < 2 /n^2. Now consider the probability that the treap has depth greater than 10 ln n. Even though the distributions of different nodes’ depths are not independent, we can conservatively bound the probability of failure as follows:
Pr
ï max k
depth ( k ) > 8 ln n
ò = Pr
∧^ n
k = 1
( depth ( k ) > 8 ln n )
∑^ n
k = 1
Pr[ depth ( k ) > 8 ln n ] <
n
This argument implies more generally that for any constant c , the depth of the treap is greater than c ln n with probability at most 2 /nc^ ln^ c − c^. We can make the failure probability an arbitrarily small polynomial by choosing c appropriately. É
This lemma implies that any search, insertion, deletion, or merge operation on an n -node treap requires O (log n ) time with high probability. In particular, the expected worst-case time for each of these operations is O (log n ).
(a) Prove that for any r , the node with the r th smallest priority has expected depth O (log r ). (b) Prove that an n -node heater has depth O (log n ) with high probability. (c) Describe algorithms to perform the operations INSERT and DELETEMIN in a heater. What are the expected worst-case running times of your algorithms? In particular, can you express the expected running time of INSERT in terms of the priority rank of the newly inserted item?
© c Copyright 2008 Jeff Erickson. Released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License (http://creativecommons.org/licenses/by-nc-sa/3.0/). Free distribution is strongly encouraged; commercial distribution is expressly forbidden. See http://www.cs.uiuc.edu/~jeffe/teaching/algorithms/ for the most recent revision.