Skip to content

Commit 14fe88c

Browse files
01.01.24
1 parent 1fb2b94 commit 14fe88c

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -574,31 +574,30 @@ class HashTable:
574574

575575
1. **Linear Probing**: When a collision occurs, investigate cells in a consistent sequence. The operation is mathematically represented as:
576576

577-
$$
578-
(h(k) + i) \mod m, \quad \text{for} \ i = 0, 1, 2, \ldots
579-
$$
577+
$$
578+
(h(k) + i) \mod m, \quad \text{for} \ i = 0, 1, 2, \ldots
579+
$$
580580

581-
Here, $h(k)$ is the key's hash value, $m$ is the table size, and $i$ iterates within the modulo operation.
581+
Here, $h(k)$ is the key's hash value, $m$ is the table size, and $i$ iterates within the modulo operation.
582582

583-
![Linear Probing](https://upload.wikimedia.org/wikipedia/commons/b/bf/Linear_ probing_visualisation.svg)
584583

585584
2. **Quadratic Probing**: The cells to search are determined by a quadratic function:
586585

587-
$$
588-
(h(k) + c_1i + c_2i^2) \mod m
589-
$$
586+
$$
587+
(h(k) + c_1i + c_2i^2) \mod m
588+
$$
590589

591-
Positive constants $c1$ and $c2$ are used as increment factors. If the table size is a prime number, these constants can equal 1 and 1, respectively. This scheme can still result in clustering.
590+
Positive constants $c1$ and $c2$ are used as increment factors. If the table size is a prime number, these constants can equal 1 and 1, respectively. This scheme can still result in clustering.
592591

593-
![Quadratic Probing](https://upload.wikimedia.org/wikipedia/commons/9/98/Quadratic_probing_visualisation.svg)
592+
![Linear and Quadratic probing in hashing](https://firebasestorage.googleapis.com/v0/b/dev-stack-app.appspot.com/o/hash-tables%2Flinear-and-quadratic-probing-in-hashing.webp?alt=media&token=2aca1d94-be59-4c05-aa4d-2b3d50899053)
594593

595-
3. **Double Hashing**: Unlike with linear or quadratic probing, the second hash function $h_2(k)$ computes the stride of the probe. The operation is:
594+
4. **Double Hashing**: Unlike with linear or quadratic probing, the second hash function $h_2(k)$ computes the stride of the probe. The operation is:
596595

597-
$$
598-
(h(k) + ih_2(k)) \mod m
599-
$$
596+
$$
597+
(h(k) + ih_2(k)) \mod m
598+
$$
600599

601-
**Note**: It's crucial for the new probe sequence to cover all positions in the table, thereby ensuring that every slot has the same probability of being the data's final location.
600+
**Note**: It's crucial for the new probe sequence to cover all positions in the table, thereby ensuring that every slot has the same probability of being the data's final location.
602601
<br>
603602

604603
## 11. Explain the _Time_ and _Space Complexity_ of a _Hash Table_.

0 commit comments

Comments
 (0)