-
Notifications
You must be signed in to change notification settings - Fork 13.9k
translation: update binary_search_recur.md #1663
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
base: main
Are you sure you want to change the base?
Conversation
@krahets I wonder how to eliminate those commit histories. Do you have any idea? |
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.
Great work! @yanedie please consider my suggestions.
@@ -1,40 +1,40 @@ | |||
# Divide and conquer search strategy | |||
|
|||
We have learned that search algorithms fall into two main categories. | |||
We have learned from the [chapter 10.5](../chapter_searching/searching_algorithm_revisited.md) that search algorithms fall into two main categories. |
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'm not sure if this reference is necessary?
|
||
In fact, **search algorithms with a time complexity of $O(\log n)$ are usually based on the divide-and-conquer strategy**, such as binary search and trees. | ||
In fact, **search algorithms with a time complexity of $O(\log n)$ are typically based on the divide-and-conquer strategy**, such as binary search and tree. |
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 should be "trees" instead of "tree" because we are not referring to a specific one.
- **The problem can be divided**: Binary search recursively divides the original problem (searching in an array) into subproblems (searching in half of the array), achieved by comparing the middle element with the target element. | ||
- **Subproblems are independent**: In binary search, each round handles one subproblem, unaffected by other subproblems. | ||
- **The solutions of subproblems do not need to be merged**: Binary search aims to find a specific element, so there is no need to merge the solutions of subproblems. When a subproblem is solved, the original problem is also solved. | ||
- **Dividing the problem**: Binary search recursively divides the original problem (searching in the full array) into subproblems (searching in half of the array) by comparing the middle element with the target element. |
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.
"Dividing the problem" -> "Dividable problem", this aligns better with the other headers
|
||
Divide-and-conquer can enhance search efficiency because brute-force search can only eliminate one option per round, **whereas divide-and-conquer can eliminate half of the options**. | ||
Divide-and-conquer improves search efficiency. This is because, in brute-force search, only one option can be eliminated per round. In contrast, **divide-and-conquer search eliminates half of the options in each round**. |
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.
"This is because, in brute-force search" -> "Since in brute-force search" might be more concise.
2. Recursively solve the subproblem reduced by half in size, which could be $f(i, m-1)$ or $f(m+1, j)$. | ||
3. Repeat steps `1.` and `2.`, until `target` is found or the interval is empty and returns. | ||
1. Calculate the midpoint $m$ of the search interval $[i, j]$ to eliminate half of the search space. | ||
2. Recursively solve the subproblem on the reduced interval, either $f(i, m-1)$ or $f(m+1, j)$. |
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.
"reduced interval" -> "reduced search space" keep consistent with previous wording
3. Repeat steps `1.` and `2.`, until `target` is found or the interval is empty and returns. | ||
1. Calculate the midpoint $m$ of the search interval $[i, j]$ to eliminate half of the search space. | ||
2. Recursively solve the subproblem on the reduced interval, either $f(i, m-1)$ or $f(m+1, j)$. | ||
3. Repeat steps `1.` and `2.`, until `target` is found or the interval becomes empty. |
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.
Same here, replace interval with search space.
If you don't want those commits to show up, a good way might be to fork a new branch from krahets:main for this PR and copy your changes into it. But you might need to create a new PR for this so it depends on you. |
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: