Skip to content

Commit

Permalink
Update 11.2.md
Browse files Browse the repository at this point in the history
  • Loading branch information
walkccc committed Mar 16, 2019
1 parent dc386ff commit b87d024
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions docs/Chap11/11.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,25 @@ $$

> Demonstrate what happens when we insert the keys $5, 28, 19, 15, 20, 33, 12, 17, 10$ into a hash table with collisions resolved by chaining. Let the table have $9$ slots, and let the hash function be $h(k) = k \mod 9$.
Start with a bit vector $b$ which contains a $1$ in position $k$ if $k$ is in the dynamic set, and a $0$ otherwise.
Let us number our slots $0, 1, \dots, 8$.

- To search, we return true if $b[x] = 1$.
- To insert $x$, set $b[x] = 1$.
- To delete $x$, set $b[x] = 0$.

Each of these takes $O(1)$ time.

Let us number our slots $0, 1 ... 8$.
Then our resulting hash table will look like following:

| Index | Data |
| ----- | ------------------ |
| 0 ||
| 1 | 10 ---> 19 ---> 28 |
| 2 | 20 |
| 3 | 12 |
| 4 ||
| 5 | 5 |
| 6 | 33 ---> 15 |
| 7 ||
| 8 | 17 |
$$
\begin{array}{c|l}
h(k) & \text{keys} \\\\
\hline
0 \mod 9 & \\\\
1 \mod 9 & 28 \to 19 \to 10 \\\\
2 \mod 9 & 20 \\\\
3 \mod 9 & 12 \\\\
4 \mod 9 & \\\\
5 \mod 9 & 5 \\\\
6 \mod 9 & 15 \to 33 \\\\
7 \mod 9 & \\\\
8 \mod 9 & 17
\end{array}
$$

## 11.2-3

Expand Down

0 comments on commit b87d024

Please sign in to comment.