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.

406 DISCRETE PROBABILITY<br />

The mean value of A(hl , . . . , &), obtained by summing over all m” possibilities<br />

(hl , . . . , &) and dividing by mn, will be the same as the mean value<br />

we obtained be<strong>for</strong>e in (8.g4), But the variance of A(hl , , h,) is something<br />

different; this is a variance of mn averages, not a variance of m” .n probe<br />

counts. For example, if m == 1 (so that there is only one list), the “average”<br />

value A(hl, . . . ,&) = A(l). . . , 1) is actually constant, so its variance VA is<br />

zero; but the number of probes in a successful search is not constant, so the<br />

variance VP is nonzero. But the VP is<br />

We can illustrate this difference between variances by carrying out the nonzero “‘yin an<br />

election year.<br />

calculations <strong>for</strong> general m and n in the simplest case, when sk = l/n <strong>for</strong><br />

1 < k 6 n. In other words, we will assume temporarily that there is a uni<strong>for</strong>m<br />

distribution of search keys. Any given sequence of hash values (h, , . , h)<br />

defines m lists that contain respectively (n, ,nz, . . . ,n,) entries <strong>for</strong> some<br />

numbers ni, where<br />

nl+n2+...+n, = n.<br />

A successful search in which each of the n keys in the table is equally likely<br />

will have an average running time of<br />

(l+...+nl) + (l+...+nz) +...+ (l+...+n,)<br />

A(h,,...,h,) = -<br />

n<br />

nl (nlfl) + nz(n2+1) + . . + n,(n,+l)<br />

=-<br />

2n<br />

n:+n:+...+&+n<br />

zz-<br />

2n<br />

probes. Our goal is to calculate the variance of this quantity A(hl , . . . , &),<br />

over the probability space cionsisting of all m” sequences (hl , . . . , h,).<br />

The calculations will be simpler, it turns out, if we compute the variance<br />

of a slightly different quantity,<br />

We have<br />

B(h,,...,h,) =(?‘)+(T)+...+(y).<br />

A(h,, . . . ,G = 1 +B(h,...,h,)/n,<br />

hence the mean and varianc:e of A satisfy<br />

EA = 1,;; VA = $. (8.99)

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

Saved successfully!

Ooh no, something went wrong!