5.20
template <typename HashedObj, typename Object>
class Pair
{
{
public:
Dictionary( ) {}
void insert( const HashedObj & key, const Object & definition )
{items.insert(Pair<HashedObj,Object>(key, definition));}
};
5.22 Consider the function on the random variable X, Ia (X) to be 1 if X> a, and 0 otherwise. Ia() is called an
indicator random variable . If a > 0, then aIa(X) < X since if X < a, the left size is 0 and if X > a we have
a < X. Taking the expectation of both sides we have :
Thus aPr(X> a)< E(X) and dividing by a (since a was assumed greater than 0) we have
5.23 The probability of a rehash (failed insertion) at the point when the table is half full is low, on the order of
1% or less. The probability falls with increased table size. Below are the results of two trials with random
insertion data. The probabilities may be even lower if we modify the hopscotch table to continue linear
probing past the end of the table to wrap around to the beginning.