-
Notifications
You must be signed in to change notification settings - Fork 13k
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: Update binary_search_insertion.md #1554
base: main
Are you sure you want to change the base?
Conversation
- The given array does not contain decimals, meaning we do not need to worry about how to handle equal situations. | ||
- Since this method introduces decimals, the variable `target` in the function needs to be changed to a floating point type (no change needed in Python). | ||
- Since the given array does not contain decimals, this means we do not need to worry about handling equal cases. | ||
- Because this method introduces decimals, the variable `target` in the function needs to be changed to a floating point type (no change needed in Python). |
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.
Since has a slightly more formal tone than Because, Consider choosing one for consistency throughout the document."
@@ -21,27 +21,27 @@ In these cases, simply return $-1$. The code is as follows: | |||
|
|||
## Find the right boundary | |||
|
|||
So how do we find the rightmost `target`? The most straightforward way is to modify the code, replacing the pointer contraction operation in the case of `nums[m] == target`. The code is omitted here, but interested readers can implement it on their own. | |||
How do we find the rightmost occurrence of `target`? The most straightforward way is to modify the traditional binary search logic by changing how we adjust the search boundaries in the case of `nums[m] == target`. The code is omitted here. If you are interested, try to implement the code on your own. |
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 traditional binary search logic --> the traditional binary search algorithm " may be better
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 logic of the code changes under the condition 'nums[m] == target', so I chose "logic" rather than "algorithm. " It's more precise while the other word is more general.
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.
Got it, that's fine
@@ -21,27 +21,27 @@ In these cases, simply return $-1$. The code is as follows: | |||
|
|||
## Find the right boundary | |||
|
|||
So how do we find the rightmost `target`? The most straightforward way is to modify the code, replacing the pointer contraction operation in the case of `nums[m] == target`. The code is omitted here, but interested readers can implement it on their own. | |||
How do we find the rightmost occurrence of `target`? The most straightforward way is to modify the traditional binary search logic by changing how we adjust the search boundaries in the case of `nums[m] == target`. The code is omitted here. If you are interested, try to implement the code on your own. |
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.
You can directly use "try implementing the code on your own"
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.
Just respect the author's original text.
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.
OK, just use your statement
1. Perform a binary search, get an arbitrary index of `target`, denoted as $k$. | ||
2. Start from index $k$, and perform a linear search to the left until the leftmost `target` is found and return. | ||
1. Perform a binary search to find any `target`'s index, say $k$. | ||
2. Starting from index $k$, perform a linear search to the left until the leftmost `target` is found and return. |
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 tenses of the two paragraphs are inconsistent. Perform and Starting
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 from index
|
||
The requirement to insert `target` to the left of equal elements means that the newly inserted `target` replaces the original `target` position. Thus, **when the array contains `target`, the insertion point index is the index of that `target`**. | ||
The requirement to insert `target` to the left of equal elements means that the newly inserted `target` will replace the original `target` position. In other words, **when the array contains `target`, the insertion point is indeed the index of that `target`**. |
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 other words" may be some colloquialisms
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 phrase 'in other words' is common in many documents.
Examples:
https://react.dev/learn/updating-objects-in-state#treat-state-as-read-only
https://python.langchain.com/docs/versions/release_policy/#what-is-a-api-stability
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.
OK
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: