You are on page 1of 30

Contents

• Basics of probability
• Random Variable
• Some basic probability distributions
• Skip List
• Mark Operation
Randomized Algorithm
• Its step are not only determined by the
previous step.
• it is determined by the prior steps as well as
output of the random number generator.
• Here we don't have worst case scenario.
instead we calculate the probability of running
time exceeding certain threshold value.
Confidence bound
• n−exponential probability – The amount of
resource
n
used is at most αf(n) with probability
1−O(β ) , β > 1.
• n−polynomial probability – The amount of
resource used is at most αf(n) with probability
c
1−O(n ) .
• n−log probability – The amount of resource
used is at most αf(n) with probability
c
1−O(log(n ) ) .
Contd.
• n−constant probability – The amount of
resource used is at most αf(n) with probability
α
1−O(β ) .
Basics of probability

• Pr(φ)=0
c
• Pr(E )=1−Pr(E)
• Pr(E1) ≤ Pr(E2) if E1 ⊆ E2
• Pr(E1 ∪ E2) = Pr(E1) + Pr(E2) − Pr(E1 ∩ E2) ≤
Pr(E1) + Pr(E2) (Boole’s inequality)
Contd.
Conditional probability.
• Pr(E1/E2) =Pr(E1 ∩ E2) , provided Pr(E2) = 0.
Pr(E2)

• Independent Event.

Baye’s Rule .
Pr(E2/E1).Pr(E1)
Pr(E1/E2) =
Pr(E2)
Random Variable

A random variable is a function from a sample


space into the set of real numbers. For a
random variable X, R(X) denotes the range of
the function X.
Probability Distribution
• Bernoulli Distribution
R(X) = {0,1}, P r(X = 1) = p, P r(X = 0) = 1 − p

• Binomial Distribution
R(X) = {0, 1, 2, . . . , n}
n k n-k
Pr(X = k) = b(k,n,p) = ( )p q for k = 0,1,...,n
K
Contd.
• Geometric distribution
K-1
R(X) = {1,2,...,∞} , Pr(X = k) = q p, for k =
1,2,...,∞
• Negative Binomial distribution
R(X) = {0,1,2,...} ,
K-1 n K-n
Pr(X = k) = ( n-1 ) p q if k ≥ n
Pr(X = k) = 0 if 0 ≤ k < n
Sum of Random variables
Sn = X1 + X2 + · · · + Xn.
Where X1,X2 … Xn are independent random
variables.
Properties :
1. If Xi is a Bernoulli random variable with
parameter p then X is a binomial random
variable with parameters n and p.
Contd.
2. If Xi is a geometric random variable with
parameter p, then X is a negative binomial
with parameters n and p.
3. If Xi is a (negative) binomial random variable
with parameters r and p then X is a (negative)
binomial random variable with parameters nr
and p.
Skip List
• Data structures implemented using
randomness.
• Operation are very simple comparable to
operation on linked list.
• Performance equivalent to balanced tree
structures
Skip List

• Key Set
S = { k1 , k2 , k3 …… kn}.

• Keys have the following properties


k1 < k2 < k3 …….. < kn
Leveling of S with r level.

Let S0, S1, S2, . . . , Sr be a collection of


sets satisfying

S = S0 ⊇ S1 ⊇ S2 ⊇ ··· ⊃ Sr = φ
Implementation of skip list
• Each Si will be implemented as List Li .

• Items in Li will arranged in increasing order.

• -∞ will be attached at the beginning of the list


∞ will be attached at the end of the list.
Contd.
• The box containing a key k in Li will have a
pointer to the box containing k in L i−1 called
descent pointer.

• The links connecting items of the same list are


called horizontal pointers.
Contd.
• To get Si+1 from Si, for each element k of Si
toss a coin and include k in Si+1 iff we get
success in the coin toss.
OR
• For each element k we will tossed a coin until
we get failure . Let h be the number of coin
tossed. We will include k in further h level
from L0.
Skip List
Structural Properties of Skip Lists
• Number of level in skip list
r = 1 + max{ Zi }
Zi is the level for each element ki

• we will calculate Pr(r > k).


Pr(r ≥ k) ≤ np k−1 (Boole ‘s inequality)
Putting k = 4Log(n) + 1
Contd.
3
Pr(r ≥ 4Log(n) + 1) ≤ 1/n

• Calculation of Expectation of r

E(r) = Pr( r ≥ i )
i=1
4Log(n)

=  Pr( r ≥ i ) +  Pr ( r ≥ i )
I=1 4log(n) + 1
Contd.

E(r) ≤ 4Log(n) + 1

Therefore
E(r) = O(log n)
Space Complexity
The space complexity, | SL | is given by
|SL|=Z1 +Z2 +···+Zn +n+2r+2.
we know that r = O(log n), let calculate
Z = Z1 + Z2 + · · · + Zn.
Since Z is a negative binomial distribution
Pr(Z > 4n) = Pr(X < n) where X is a binomial
distribution with parameters 4n and p
Contd.
Let us assume p = ½
From Chernoff bound we get
n 3n
Pr( X < n ) ≤ (2n/n) (2n/3n)
-n
Pr( X < n ) ≤(27/16)

Therefore the space complexity of SL is O(n)


Dictionary Operation
Mark Operation

• The procedure Mark takes an arbitrary value x


as input and marks in each level the box
containing the largest key that is less than x.

• insertion, deletion or search are done next to


the marked boxes.
Mark Operation
• Mark procedure

1. Procedure Mark begins its computation at the


box containing −∞ in level r.

1. At any current level, we traverse along the level


using horizontal pointers until we find that the
next box is containing a key larger or equal to x.
Then we mark the current box and use the
descent pointer to reach the next lower level and
continue the same process.
Contd.
3. The procedure stops after marking a box in
level 0.
Analysis of Dictionary Operations
• Cost of Search, Insert and Delete operations are
dominated by the cost of Mark procedure. Hence
we shall analyze only the Mark procedure.
• The number of edges traversed by Mark(x) for
any fixed x is given by | P |= r+(Y0 +Y1 +Y2
+···+Yr−1) where Yi is a geometric random
variable with parameters 1 − p and r is the
random variable denoting the number of levels in
the Skip List.
Contd.
Let Hr = Y0 +Y1 +Y2 +···+Yr−1
Pr(Hr >16logn) ≤ (1+4logn)Pr(H4logn >16logn)+
1
We can show
3
Pr(H4logn>16logn) < 1/n
Therefore
2
Pr(Hr >16logn) < 1/n
Contd.
Also we can show expectation of Hr
E(Hr) ≤ 16 log n + c = O(log n).

Therefore the Dictionary operations Insert ,


Delete, and Search take O(log n) expected
time when implemented using Skip Lists.
Questions
• Explain Bernoulli , binomial , geometric ,
negative binomial distribution.
• Explain skip list.
• Explain mark operation.
• Derive high confidence bound and expected
value of levels in skip list.

You might also like