Title: Hashed Files Text Versus Binary
1Hashed Files Text Versus Binary
2Hashed Filesa file that is searched using one of
the hashing methods
- User gives the key, the function maps the key to
the address and passes it to the operating system
then the record is retrieved
3Hashing Methods
- Direct Hashing
- Modulo Division
- Digit Extraction
- Mid-square
- Folding
- Rotational
- Pseudorandom
4Direct Hashing Methodthe key is obtained
without any algorithmic manipulation
- Contains a record for every possible key
- Limited situations for this method
- Very powerful because it guarantees that there
are no synonyms or collisions
5Modulo Division Method(division remainder
hashing) divides the key by the file size and
uses the remainder plus one for the address
- Algorithm works with any list size but a prime
number produces fewer collisions than other list
sizes - The list size in the equation below is the number
of elements in the file
6Digit Extraction Methodselected digits are
extracted from the key and used as the address
- For example if you use a six digit employee
number to hash to a three digit address you could
select the first, third and fourth digits and use
them as the address
7Collisionoccurs when a hashing algorithm
produces an address for an insertion and that
address is already occupiedSynonymstwo or more
keys the hatch to the same home addressHome
Addressthe first address produced by the hashing
algorithmPrime Areathe memory that contains
the home address
8Collision Resolution
- Open Addressing Resolution- when a collision
occurs, the prime area addresses are searched for
an opened or unoccupied record where the new data
can be placed - Linked List Resolution-eliminates the probability
of future collisions where the first record is
stored in the home address, but it contains a
pointer to the second record - Bucket Hashing-uses a location that can
accommodate multiple data units to reduce
collision - Combination Approaching-uses several approaches
to resolve the collision
9Text File
- File of characters
- Cannot contain integers, floating point numbers
or any other data structures in their internal
memory format - In order to store these data types they must be
converted to their character equivalent formats - The most well known text files are file streams
for key boards, monitors and printers
10Binary Files
- Collection of data stored in the internal format
of the computer - Data can be an integer, a floating point number,
a character or any other structured data (except
a file) - Contains data that is meaningful only if they are
properly interpreted by the program
11The End