// "collision" = two records have the same has value so need // to be stored at the same position in the hash table. If // this happens, hash tables will need to do something // clever to recover (like linear probing or chaining), // otherwise they will be useless. // If a hash table has size H, what is the probability that // you can add N random records without any collisions? #include void main() { int h; cout << "Hash table size? "; cin >> h; double probok = 1.0; for (int n=1; n<=h; n+=1) { probok = probok * (h-(n-1)) / h; cout << "after inserting " << n << " things, " << "probability all OK = " << probok << "\n"; } } // We see that the results are hopeless.