Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Code Description For Code Section In Markdown #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 03-hashing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The hash function we choose should:
We'll make use of a generic string hashing function, expressed below in
pseudocode.

```
```c
function hash(string, a, num_buckets):
hash = 0
string_len = length(string)
Expand All @@ -41,7 +41,7 @@ character. We'll use ASCII character codes for this.

Let's try the hash function out:

```
```c
hash("cat", 151, 53)

hash = (151**2 * 99 + 151**1 * 97 + 151**0 * 116) % 53
Expand All @@ -52,7 +52,7 @@ hash = 5

Changing the value of `a` give us a different hash function.

```
```c
hash("cat", 163, 53) = 3
```

Expand Down
4 changes: 2 additions & 2 deletions 04-collisions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For an overview of other types of collision resolution, see the

The index that should be used after `i` collisions is given by:

```
```c
index = hash_a(string) + i * hash_b(string) % num_buckets
```

Expand All @@ -29,7 +29,7 @@ will cause the hash table to try to insert the item into the same bucket over
and over. We can mitigate this by adding 1 to the result of the second hash,
making sure it's never 0.

```
```c
index = (hash_a(string) + i * (hash_b(string) + 1)) % num_buckets
```

Expand Down