translation: update binary_search_recur.md#1663
translation: update binary_search_recur.md#1663yanedie wants to merge 14 commits intokrahets:mainfrom
Conversation
|
@krahets I wonder how to eliminate those commit histories. Do you have any idea? |
| # 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.
I'm not sure if this reference is necessary?
| - **Adaptive search**: It utilizes a unique data structure or prior information, with a time complexity of $O(\log n)$ or even $O(1)$. | ||
|
|
||
| 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.
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.
"Dividing the problem" -> "Dividable problem", this aligns better with the other headers
| - **No subproblem solution merging**: Binary search aims to find a specific element, so there is no need to merge the solutions of subproblems. Solving the subproblem inherently solves the original problem. | ||
|
|
||
| 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.
"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.
"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.
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: