
- Data Structures & Algorithms
- DSA - Home
- DSA - Overview
- DSA - Environment Setup
- Algorithm
- DSA - Algorithms Basics
- DSA - Asymptotic Analysis
- DSA - Greedy Algorithms
- DSA - Divide and Conquer
- DSA - Dynamic Programming
- Data Structures
- DSA - Data Structure Basics
- DSA - Array Data Structure
- Stack & Queue
- DSA - Stack
- DSA - Expression Parsing
- DSA - Queue
- Searching Techniques
- DSA - Linear Search
- DSA - Binary Search
- DSA - Interpolation Search
- DSA - Hash Table
- Sorting Techniques
- DSA - Sorting Algorithms
- DSA - Bubble Sort
- DSA - Insertion Sort
- DSA - Selection Sort
- DSA - Merge Sort
- DSA - Shell Sort
- DSA - Quick Sort
- Graph Data Structure
- DSA - Graph Data Structure
- DSA - Depth First Traversal
- DSA - Breadth First Traversal
- Tree Data Structure
- DSA - Tree Data Structure
- DSA - Tree Traversal
- DSA - Binary Search Tree
- DSA - AVL Tree
- DSA - Spanning Tree
- DSA - Heap
- DSA Useful Resources
- DSA - Questions and Answers
- DSA - Quick Guide
- DSA - Useful Resources
- DSA - Discussion
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 Li. 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 Li 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 Articles
- 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
- Rectangle Data in Data Structure
- Deaps in Data Structure
- Quadtrees in Data Structure
- Frame Structure for OFDMA with Time Division Duplexing
- Halfedge data structure
- Booleβs Inequality in Data Structure
- Bayesβ Rule in Data Structure
