09.12.2012 Views

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

402 DISCRETE PROBABILITY<br />

Let sj be the probability that we are searching <strong>for</strong> the jth key that was<br />

inserted into the table. Then<br />

Pr(w) = sk/mn (8.87)<br />

if w is the event (8.86). (Some applications search most often <strong>for</strong> the items<br />

that were inserted first, or <strong>for</strong> the items that were inserted last, so we will not<br />

assume that each Sj = l/n.) Notice that ,&l Pr(w) = Et=, sk = 1, hence<br />

(8.87) defines a legal probability distribution.<br />

The number of probes P in a successful search is p if key K was the pth<br />

key to be inserted into its hst. There<strong>for</strong>e<br />

P = [h, = h-k] + [hz = hkl + . . . + [hk =hkl ;<br />

or, if we let Xj be the random variable [hj = hk], we have<br />

P = x1 +& + “‘+xk. (8.88)<br />

Suppose, <strong>for</strong> example, that we have m = 10 and n = 16, and that the hash<br />

values have the following “random” pattern: Where have I seen<br />

that pattern be<strong>for</strong>e?<br />

(h-l,..., h,6)=3 141592653589793;<br />

(Pl,. . *, P,~)=1112111122312133.<br />

The number of probes Pj needed to find the jth key is shown below hi.<br />

Equation (8.88) represents P as a sum of random variables, but we can’t<br />

simply calculate EP as EX, $-. . .+EXk because the quantity k itself is a random<br />

variable. What is the probability generating function <strong>for</strong> P? To answer this<br />

question we should digress #a moment to talk about conditional probability. Equation (8.43) was<br />

If A and B are events in a probability space, we say that the conditional a1so a momentary<br />

digression.<br />

probability of A, given B, is<br />

F’r(cu g A n B)<br />

Pr(wEAIwEB) = - Pr(wCB) ’<br />

For example, if X and Y are random variables, the conditional probability of<br />

the event X = x, given that Y = y, is<br />

Pr(X=x and Y=y)<br />

Pr(X=xlY=y) = - Pr(Y=y) ’<br />

(8.90)<br />

For any fixed y in the range of Y, the sum of these conditional probabilities<br />

over all x in the range of X is Pr(Y =y)/Pr(Y =y) = 1; there<strong>for</strong>e (8.90)<br />

defines a probability distribution, and we can define a new random variable<br />

‘X/y’ such that Pr(Xly =x) = Pr(X =x 1 Y =y).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!