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 insertion_sort.md #1630

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

Conversation

SamJin98
Copy link
Contributor

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.

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:

  • I have thoroughly reviewed the code, focusing on its formatting, comments, indentation, and file headers.
  • I have confirmed that the code execution outputs are consistent with those produced by the reference code (Python or Java).
  • The code is designed to be compatible on standard operating systems, including Windows, macOS, and Ubuntu.

Copy link
Contributor

@K3v123 K3v123 left a comment

Choose a reason for hiding this comment

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

Hi Sam
thanks for the hard work. here are some of my suggestions.

kind regards

@@ -2,20 +2,20 @@

<u>Insertion sort</u> is a simple sorting algorithm that works very much like the process of manually sorting a deck of cards.

Specifically, we select a pivot element from the unsorted interval, compare it with the elements in the sorted interval to its left, and insert the element into the correct position.
Specifically, we select a key element from the unsorted interval, compare it with the elements in the sorted interval to its left, and insert the element into the correct position.
Copy link
Contributor

Choose a reason for hiding this comment

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

"pivot" may be better
reason:
key might introduce confusion as key is typically used in other contexts eg key-value etc

alternatively (i wouldn't recommend this because its not direct and I think pivot is commonly used to describe this) you can do "reference"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey Kevin, thanks for the feedback. I actually did some research before translating that section, I noticed “pivot” is often associated with quicksort, while many references and tutorials use “key” or “base” for insertion sort. I see how “key” could confuse readers who think of key-value pairs, but it’s also common in insertion sort examples. Maybe we can ask around for more opinions and see which term is best.


The figure below shows the process of inserting an element into an array. Assuming the pivot element is `base`, we need to move all elements between the target index and `base` one position to the right, then assign `base` to the target index.
The figure below illustrates how an element is inserted into the array. Assuming the key element is `base`, we need to shift all elements from the target index up to `base` one position to the right, then assign `base` to the target index.
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above key -> pivot

2. The second element of the array is taken as `base`, and after inserting it into the correct position, **the first two elements of the array are sorted**.
3. The third element is taken as `base`, and after inserting it into the correct position, **the first three elements of the array are sorted**.
4. And so on, in the last round, the last element is taken as `base`, and after inserting it into the correct position, **all elements are sorted**.
1. Consider the first element of the array as sorted.
Copy link
Contributor

Choose a reason for hiding this comment

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

optional:
this depends.... in CN "初始状态下" is "Initially" however if target audience prefer more instructional style then that's fine.
@krahets which do you think is better?

Copy link
Owner

@krahets krahets Feb 3, 2025

Choose a reason for hiding this comment

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

The updated version sounds great as well!

en/docs/chapter_sorting/insertion_sort.md Outdated Show resolved Hide resolved
en/docs/chapter_sorting/insertion_sort.md Outdated Show resolved Hide resolved
en/docs/chapter_sorting/insertion_sort.md Outdated Show resolved Hide resolved

![Single insertion operation](insertion_sort.assets/insertion_operation.png)

## Algorithm process
## Algorithm steps
Copy link
Owner

Choose a reason for hiding this comment

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

Please create a new PR to update all Algorithm process to Algorithm steps if we decide to make this change.

Copy link
Contributor

@K3v123 K3v123 left a comment

Choose a reason for hiding this comment

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

I had a second thought about the 'key' part. if its in the insertion sort section, then it should be fine.... other than that its just what Krahets suggested... if its a new PR I will approve that one again.

thanks for the hard work!

sincerely,
Kevin

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