Page 96 - Data Structures Handout_Neat
P. 96
converting them into irreversible hash values.
• Caching: Hashing helps quickly locate cached data in memory.
• Compilers: Symbol tables use hashing to manage variables and functions
efficiently.
• Networking: Hashing is used in routing algorithms and packet distribution.
9.1.3 Comparison with Other Search Techniques
Hashing provides significant advantages over other search techniques:
• Linear Search: Requires ( )time, inefficient for large datasets.
• Binary Search: Requires (log )time, but only works on sorted data.
• Hashing: Provides (1)average time for insertion, deletion, and search, making it
ideal for large, dynamic datasets.
However, hashing is not perfect. Collisions (when two keys map to the same index)
must be handled carefully, and performance depends on the quality of the hash function and
the load factor of the hash table.
Code Example: Simple Hash Function in C++
This program demonstrates a simple hash function using the division method. Keys
are mapped to indices by taking the remainder when divided by the table size.
96

