@@ -19,7 +19,7 @@ does it work under the hood?
19
19
## Hash Functions
20
20
21
21
For a hash to work, we use a ** hash function** to determine where in memory to
22
- store a information related to that key. Later, we use the same hash function to
22
+ store information related to that key. Later, we use the same hash function to
23
23
determine where to search for a given key.
24
24
25
25
One way to think about how hashes relate to hash functions is thinking about how
@@ -29,7 +29,7 @@ author of a book, and the librarian tells us precisely where to find the book.
29
29
![ library book example] ( https://s3-us-west-2.amazonaws.com/curriculum-content/algorithms/dewey-decimal-arrangement.jpg )
30
30
31
31
In this analogy, our ** key** is the title and author of the book, which we can
32
- use to determine the appropriate card catalogue id. The card catalogue id (which
32
+ use to determine the appropriate card catalog id. The card catalog id (which
33
33
comes from the Dewey Decimal System above — think of that as our ** hash
34
34
function** ) tells us exactly where to find the book. If the book is there, we
35
35
have our book and all of the information inside. If nothing is there, there is
@@ -121,7 +121,7 @@ technique, our hash table looks like the following:
121
121
| 800 | [ "* War and Peace* " ] |
122
122
| 900 | [ "* Alexander Hamilton* " ] |
123
123
124
- In the worse case scenario, all of our inserted elements collide, and we have to
124
+ In the worst case scenario, all of our inserted elements collide, and we have to
125
125
traverse a linked list of length ` n ` to retrieve an element, so we have ** O(n)**
126
126
runtime. However, on average collisions do not occur, so we achieve constant
127
127
time for lookup, insertion and deletion _ on average_ .
@@ -137,9 +137,9 @@ the chance of a collision occurring. Some properties of a good hash function are
137
137
values.
138
138
2 . Maps similar keys to very different values - making collisions much less likely.
139
139
140
- ### Summary
140
+ ## Conclusion
141
141
142
- In this lesson we learned about ** hash tables** . Hash tables use a ** hash
142
+ In this lesson, we learned about ** hash tables** . Hash tables use a ** hash
143
143
function** to output a ** hash value** . The hash value determines where to place
144
144
the element in memory. Because a hash function produces the same hash value for
145
145
a given element, it also gives us fast lookup time to retrieve an element.
0 commit comments