-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
translation: optimize the translation of hash_map.md #1358
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Please address the comments.
en/docs/chapter_hashing/hash_map.md
Outdated
- **Deleting elements**: First, locate the element, then delete it from the array (or linked list), using $O(n)$ time. | ||
- **Inserting an element**: Simply append the element to the tail of the array (or linked list). The time complexity of this operation is $O(1)$. | ||
- **Searching for an element**: As the array (or linked list) is unsorted, searching for an element requires traversing through all of the elements. The time complexity of this operation is $O(n)$. | ||
- **Deleting an element**: In order to remove elements, we need to locate them first. Then, delete them from the array (or linked list). The time complexity of this operation is $O(n)$. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting a sentence with "Then, ..." is controversial (It's grammatically OK, but feels sudden/jarring). Just a style suggestion but maybe something like "To remove elements, we first need to locate them. After locating the elements, we delete them from the array (or linked list)..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your suggestion. However, I think changing from "Then...." to duplicated words "locate..." might not be a good idea. How about something like "To remove elements, we first need to locate them. Subsequently, we delete..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that sounds better. Now that you moved the word "first" you can even revert to using "then" in the second sentence ("To remove elements, we first need to locate them. Then, we delete them from the array"). This sounds more natural to me at least. (We could also do singular "To remove an element, we first need to locate it. Then, we delete the element from the array"). Both of these sound smoother to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it sounds better. I've changed the sentence to singular form. Have a check. 8b39df2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider my suggestions, there are a few grammar errors that needs adjustment.
en/docs/chapter_hashing/hash_map.md
Outdated
- **Adding elements**: Simply add the element to the end of the array (or linked list), using $O(1)$ time. | ||
- **Querying elements**: Since the array (or linked list) is unordered, it requires traversing all the elements, using $O(n)$ time. | ||
- **Deleting elements**: First, locate the element, then delete it from the array (or linked list), using $O(n)$ time. | ||
- **Inserting an element**: Simply append the element to the tail of the array (or linked list). The time complexity of this operation is $O(1)$. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for simplicity, from line 11 to 13:
"Inserting an element" -> "Inserting elements"
"Searching for an element" -> "Searching elements"
"Deleting an element" -> "Deleting elements"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion taken.
en/docs/chapter_hashing/hash_map.md
Outdated
|
||
## Common operations of hash table | ||
|
||
Common operations of a hash table include initialization, querying, adding key-value pairs, and deleting key-value pairs, etc. Example code is as follows: | ||
The common operations of a hash table include: initialization, querying, adding key-value pairs, and deleting key-value pairs. Here is an example code: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in "The common operations", "The" is not needed, "Common operations of a ..." is more concise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
en/docs/chapter_hashing/hash_map.md
Outdated
|
||
```shell | ||
12836 % 100 = 36 | ||
20336 % 100 = 36 | ||
``` | ||
|
||
As shown in the figure below, both student numbers point to the same name, which is obviously incorrect. This situation where multiple inputs correspond to the same output is known as <u>hash collision</u>. | ||
As shown in the figure below, both student IDs point to the same name, which is obviously incorrect. This situation where multiple inputs correspond to the same output is called as <u>hash collision</u>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"called as " -> "called", "called as" is not the correct syntax here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion taken! "called" or "known as" are more commonly used.
en/docs/chapter_hashing/hash_map.md
Outdated
|
||
![Abstract representation of a hash table](hash_map.assets/hash_table_lookup.png) | ||
|
||
Apart from hash tables, arrays and linked lists can also be used to implement querying functions. Their efficiency is compared in the table below. | ||
In addition to hash tables, arrays and linked lists can also be used to implement query functionality, but the time complexity is different. The table below shows the comparison of time efficiency for common operations among them: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the original translation, also, "for common operations among them" is not a correct syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion taken! Syntax is correct, but seems a little bit wordy.
@@ -1,30 +1,30 @@ | |||
# Hash table | |||
|
|||
A <u>hash table</u> achieves efficient element querying by establishing a mapping between keys and values. Specifically, when we input a `key` into the hash table, we can retrieve the corresponding `value` in $O(1)$ time. | |||
A <u>hash table</u>, also known as a <u>hash map</u>, is a data structure that establishes a mapping between keys and values, enabling efficient element retrieval. Specifically, when we input a `key` into the hash table, we can retrive the corresponding `value` in $O(1)$ time complexity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trailing "complexity" in this sentence is unnecessary, "in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O(1) time is rarely seen. O(1) time complexity or O(1) complexity or O(1) may be more acceptable.
|
||
Observations reveal that **the time complexity for adding, deleting, and querying in a hash table is $O(1)$**, which is highly efficient. | ||
It can be seen that **the time complexity for operations (insertion, deletion, searching, and modification) in a hash table is $O(1)$**, which is highly efficient. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"It can be seen that" -> "The table shows that"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still prefer "It can be seen that", which fits better to the Chinese version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personally, i think "it can be seen that" is a bit chinglish, but ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the refined version at: 5ec77fb
@@ -1,30 +1,30 @@ | |||
# Hash table | |||
|
|||
A <u>hash table</u> achieves efficient element querying by establishing a mapping between keys and values. Specifically, when we input a `key` into the hash table, we can retrieve the corresponding `value` in $O(1)$ time. | |||
A <u>hash table</u>, also known as a <u>hash map</u>, is a data structure that establishes a mapping between keys and values, enabling efficient element retrieval. Specifically, when we input a `key` into the hash table, we can retrive the corresponding `value` in $O(1)$ time complexity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O(1) time is rarely seen. O(1) time complexity or O(1) complexity or O(1) may be more acceptable.
|
||
Observations reveal that **the time complexity for adding, deleting, and querying in a hash table is $O(1)$**, which is highly efficient. | ||
It can be seen that **the time complexity for operations (insertion, deletion, searching, and modification) in a hash table is $O(1)$**, which is highly efficient. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still prefer "It can be seen that", which fits better to the Chinese version.
en/docs/chapter_hashing/hash_map.md
Outdated
|
||
![Abstract representation of a hash table](hash_map.assets/hash_table_lookup.png) | ||
|
||
Apart from hash tables, arrays and linked lists can also be used to implement querying functions. Their efficiency is compared in the table below. | ||
In addition to hash tables, arrays and linked lists can also be used to implement query functionality, but the time complexity is different. The table below shows the comparison of time efficiency for common operations among them: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion taken! Syntax is correct, but seems a little bit wordy.
en/docs/chapter_hashing/hash_map.md
Outdated
- **Adding elements**: Simply add the element to the end of the array (or linked list), using $O(1)$ time. | ||
- **Querying elements**: Since the array (or linked list) is unordered, it requires traversing all the elements, using $O(n)$ time. | ||
- **Deleting elements**: First, locate the element, then delete it from the array (or linked list), using $O(n)$ time. | ||
- **Inserting an element**: Simply append the element to the tail of the array (or linked list). The time complexity of this operation is $O(1)$. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion taken.
en/docs/chapter_hashing/hash_map.md
Outdated
|
||
## Common operations of hash table | ||
|
||
Common operations of a hash table include initialization, querying, adding key-value pairs, and deleting key-value pairs, etc. Example code is as follows: | ||
The common operations of a hash table include: initialization, querying, adding key-value pairs, and deleting key-value pairs. Here is an example code: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
en/docs/chapter_hashing/hash_map.md
Outdated
|
||
```shell | ||
12836 % 100 = 36 | ||
20336 % 100 = 36 | ||
``` | ||
|
||
As shown in the figure below, both student numbers point to the same name, which is obviously incorrect. This situation where multiple inputs correspond to the same output is known as <u>hash collision</u>. | ||
As shown in the figure below, both student IDs point to the same name, which is obviously incorrect. This situation where multiple inputs correspond to the same output is called as <u>hash collision</u>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion taken! "called" or "known as" are more commonly used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work!
If this pull request (PR) pertains to Chinese-to-English translation, please confirm that you have read the contribution guidelines and complete the checklist below:
If this pull request (PR) is associated with coding or code transpilation, please attach the relevant console outputs to the PR and complete the following checklist: