You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hvenev-insait opened this issue
May 27, 2024
· 2 comments
Labels
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-libsRelevant to the library team, which will review and decide on the PR/issue.
In partial_insertion_sort, an invariant is maintained that v[..i] is sorted. When a non-sorted pair v[i-1] > v[i] is encountered, they are swapped and the last element of v[..i] is shifted to the left into its correct spot. Then for some reason insertion_sort_shift_right is called on v[..i], attempting to shift v[0] to the right, which never does anything.
Before commit a3065a1, the shift was happening on v[i..] (instead of v[..i]), attempting to shift v[i] to the right, which makes more sense.
The text was updated successfully, but these errors were encountered:
Not yet. I am not sure what the best way to fix this is. Do we want to maintain the current behavior (in which case all we need to do is delete insertion_sort_shift_right), or do we want to go back to the behavior before a3065a1 (probably call insertion_sort_shift_right on v[i..] instead of v[..i])?
Also, do we have any benchmarks for that code?
jieyouxu
added
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
and removed
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
labels
Jun 4, 2024
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-libsRelevant to the library team, which will review and decide on the PR/issue.
In
partial_insertion_sort
, an invariant is maintained thatv[..i]
is sorted. When a non-sorted pairv[i-1] > v[i]
is encountered, they are swapped and the last element ofv[..i]
is shifted to the left into its correct spot. Then for some reasoninsertion_sort_shift_right
is called onv[..i]
, attempting to shiftv[0]
to the right, which never does anything.Before commit a3065a1, the shift was happening on
v[i..]
(instead ofv[..i]
), attempting to shiftv[i]
to the right, which makes more sense.The text was updated successfully, but these errors were encountered: