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

translation: Update binary_search_insertion.md #1554

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

yanedie
Copy link
Contributor

@yanedie yanedie commented Nov 11, 2024

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:

  • This PR represents the translation of a single, complete document, or contains only bug fixes.
  • The translation accurately conveys the original meaning and intent of the Chinese version. If deviations exist, I have provided explanatory comments to clarify the reasons.

@yanedie yanedie requested review from ofou December 3, 2024 14:36
en/docs/chapter_searching/binary_search_edge.md Outdated Show resolved Hide resolved
- 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).
Copy link
Contributor

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."

en/docs/chapter_searching/binary_search_edge.md Outdated Show resolved Hide resolved
@@ -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.
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.
Copy link
Contributor

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"

Copy link
Contributor Author

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.

Copy link
Contributor

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

en/docs/chapter_searching/binary_search_insertion.md Outdated Show resolved Hide resolved
en/docs/chapter_searching/binary_search_insertion.md Outdated Show resolved Hide resolved
en/docs/chapter_searching/binary_search_insertion.md Outdated Show resolved Hide resolved
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.
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Starting from index $k$" is a present participial phrase. Their tenses are the same.


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`**.
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@yanedie yanedie requested a review from pengchzn December 6, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants