These notes cover various aspects of using hashing techniques in c/c++ for handling large datasets. Topics include choosing appropriate data types for unsigned integers, using the -fd option for radixhash, evaluating progressive overflow, understanding load factors, and employing buckets for collision resolution. Additionally, the document discusses predicting the distribution of records using a poisson function.
Download Notes on Hashing Techniques and Collision Resolution in C/C++ - Prof. Douglas Heisterkamp and more Study notes Computer Science in PDF only on Docsity!
Notes on Programming Assignment 4
To get an 8-byte unsigned integer variable using C/C++ on a.cs, use unsigned long long
Need a -f d option on your radixhash program.
Note that 500 is a bad table size. It should generate more collision than using a prime number for the table size. Try a prime number and compare the results. (On a.cs, factor n will generate the prime factors for a number n .)
Evaluation of Progressive Overflow
Cost to retrieve a record is based on the search length to the record. Every time a collision occurs, the search length for a record increase.
average search length is an indicator of overflow prob- lems.
Average search length =
total search length total number of records
Average search lengths greater than 2.0 are generally con- sider unacceptable.
Buckets
Reading a block of records from a file system cost about the same as reading a single record. Reading a block at a time is used in B-trees. When used in hashing, the block of records is called a bucket.
The bucket can hold a set of records. The hash address goes to a bucket, not an individual record.
Multiple records can be placed at the same hash address. Collisions are not a problem until the bucket overflows.
Using buckets cause a large improvement in the average search length. (See Table 11.5 from book)
Predicting the Distribution of Records
Assume a random distribution of records, what is the likely behavior of hashing?
Would like to answer the following questions: What is the likelihood that - No keys will hash to a given address? - Exactly one key will hash to address? - Exactly k keys will hash to address?
This answers to the above questions can be approximated by a Poisson function.