-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
base: main
Are you sure you want to change the base?
Conversation
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.
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. |
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.
"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"
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.
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. |
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 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. |
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.
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?
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 updated version sounds great as well!
|
||
![Single insertion operation](insertion_sort.assets/insertion_operation.png) | ||
|
||
## Algorithm process | ||
## Algorithm steps |
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.
Please create a new PR to update all Algorithm process
to Algorithm steps
if we decide to make this change.
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 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
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: