Google News
logo
Data Analyst - Interview Questions
What do you mean by collisions in a hash table? Explain the ways to avoid it.
A collision in a hash table occurs when two different keys hash to the same index in the array. This situation arises because the number of possible keys typically greatly exceeds the number of indices available in the array. Even with a very good hash function, it’s impossible to avoid collisions entirely.

1. Chaining (Separate Chaining) : This method involves creating a linked list for each index of the array. When multiple keys map to the same index, their key-value pairs are stored as nodes on a linked list. When we want to look up a value, we’ll have to traverse the linked list—which is a relatively quick operation if the list is short.

2. Open Addressing (Closed Hashing) : In this method, if a collision occurs, we look for another open slot in the array instead of storing multiple items in the same slot. Several probing methods can be used to find the next open slot, including linear probing (looking at the next slot in the array), quadratic probing (looking at the next square’s slot), or double hashing (using a second hash function to determine the step size).


Write characteristics of a good data model.

Here are some characteristics of a good data model :

Simplicity : A good data model should be simple and easy to interpret. It should have a logical, clear structure that can be easily understood by both the developers and the end-users.

Robustness : A robust data model can handle a variety of data types and volumes. It should be able to support new business requirements and changes without necessitating major modifications.

Scalability : The model should be designed in a way that it can efficiently handle increases in data volume and user load. It should be able to accommodate growth over time.

Consistency : Consistency in a data model refers to the need for the model to be free from contradiction and ambiguity. This ensures that the same piece of data does not have multiple interpretations.

Flexibility : A good data model can adapt to changes in requirements. It should allow for easy modifications in structure when business requirements change.
Advertisement