11. Hashing

Overview

Data Structure Search Method Time Complexity
Unordered array Linear search $O(n)$
Ordered array Binary search $O(\log n)$
Array Random access $O(1)$

Hashing transforms input data into a fixed-size string of bytes.

Conceptual

  1. Digit Addition

  2. Polynomial Hashcode

  3. Modulus (%)

Workarounds for Collisions

Load factor ($\alpha$)

$$ \alpha = \frac{n}{N} = \frac{\text{number of items}}{\text{length of the array}}$$

1. Open Addressing

2. Separate Chaining (Closed Addressing)

Rehashing


Back to Home Next Lecture