UNIT 4 – HASHING: IMPORTANT QUESTIONS &
ANSWERS
1. What is Hashing?
• Hashing is a technique used to map data (keys) to locations in a hash table.
• It uses a hash function to compute an index based on the key.
• Hashing allows fast search, insert, and delete operations, usually in O(1) time.
2. What is a Hash Function?
• A hash function converts a key into a table index.
• A good hash function distributes keys uniformly.
• It reduces collisions and improves performance.
3. What are Collisions?
• A collision happens when two keys map to the same index in a hash table.
• Collisions are common and must be handled using collision resolution techniques.
4. Explain Collision Resolution Techniques.
• There are two major methods:
• 1) Open Addressing:
• - Linear Probing: Check next positions sequentially.
• - Quadratic Probing: Check i+1², 2², 3² positions.
• - Double Hashing: Use a second hash function when collision occurs.
• 2) Chaining:
• - Each index stores a linked list of records.
• - More flexible, no shifting of elements.
5. What is Static Hashing?
• Hash table size is fixed.
• Performance decreases when data increases.
• Causes more collisions when table becomes full.
6. What is Dynamic Hashing?
• Hash table grows or shrinks as data changes.
• Efficient for large and unpredictable datasets.
• Fewer collisions and better performance.
7. Explain Extendible Hashing.
• Extendible hashing is a dynamic hashing method.
• Uses a directory of size 2^GlobalDepth.
• Each bucket has a LocalDepth value.
• If a bucket is full and LocalDepth < GlobalDepth, bucket is split.
• If LocalDepth = GlobalDepth, directory size is doubled.
• Prevents long overflow chains and keeps access time fast.
8. Advantages of Extendible Hashing
• Search, insert, delete operations are O(1) average.
• Avoids overflow chains.
• Directory grows only when needed.
9. Disadvantages of Extendible Hashing
• Directory doubling may use extra memory.
• Implementation is more complex due to pointers.
10. What is Linear Hashing?
• Linear hashing is another dynamic hashing method.
• Table grows gradually (bucket by bucket).
• Removes need for large directory doubling.
• More space-efficient than extendible hashing in some cases.