- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Hashing by Division in Data Structure

Here we will discuss about the hashing with division. For this we use the hash function −

ℎ(𝑥) = 𝑥 𝑚𝑜𝑑 𝑚

To use this hash function we maintain an array A[0, … m – 1]. Where each element of the array is a pointer to the head of the linked list. The linked list Li is pointed to array element A[i] holds all elements x such that h(x) = i. This technique is known as hashing by chaining.

In such hash table, if we want to increase an element x, this will take O(1) time. we compute the index i = h(x). Then append or prepend x to the list Li. If we want to search or delete an element, that process is not so easy. We have to find index i = h(x). Then traverse list Li. Until we reach the desired value or the list is exhausted. This operation is taking time corresponding to the size of list L_{i}. If our set S has 0, m, 2m, 3m, …., nm elements, then all elements stored in L0 will take linear time to search and delete.

This kind of situation is very rare. For example, if S are uniformly and independently distributed in the universal set U, and u is a multiple of m, then the expected size of each list L_{i} is only n/m. In this case the searching and deleting takes *O*(1 + α) amount of time. To avoid the mentioned scenario, we have to choose m wisely. generally, we avoid m as power of 2. Taking m as a prime which is not too closer to power of 2 is recommended.

- Related Questions & Answers
- Hashing by Multiplication in Data Structure
- Universal Hashing in Data Structure
- Double Hashing in Data Structure
- Asymmetric Hashing in Data Structure
- LCFS Hashing in Data Structure
- Hashing with Chaining in Data Structure
- Robin-Hood Hashing in Data Structure
- Hashing with Open Addressing in Data Structure
- Frame Structure for OFDMA with Time Division Duplexing
- Rectangle Data in Data Structure
- Halfedge data structure
- Deaps in Data Structure
- Quadtrees in Data Structure
- Arrays Data Structure in Javascript
- Stack Data Structure in Javascript