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

Optimize Insertion Sort, update tests, & correct comments #617

Merged
merged 2 commits into from
Jan 3, 2021

Conversation

austintheriot
Copy link
Contributor

Insertion Sort Clean Up

Algorithm Change

The existing insertion sort implementation began by iterating from
0 until the end of the array, but it is only necessary to
iterate from 1 until the end of the array, since at the
0th index, there is nothing to compare to the left of
the element.

I also corrected the grammar/wording of the comments.

Test Change

In order to complete this change, I also had to update the tests
to reflect the fact that the algorithm visits each index 1 less
time.

Diagnostics

Passed all tests and linting.

The existing insertion sort implementation began by iterating from
0 until the end of the array, but it is only necessary to
iterate from 1 until the end of the array, since at the
0th index, there is nothing to compare to the left of
the element.

In order to complete this change, I also had to update the tests
to reflect the fact that the algorithm visits each index 1 less
time.

Finally, I corrected the grammar/wording of the comments.
@austintheriot austintheriot changed the title optimized for loop, updated tests, & corrected comments Optimized for loop, updated tests, & corrected comments Dec 28, 2020
@austintheriot austintheriot changed the title Optimized for loop, updated tests, & corrected comments Optimize Insertion Sort, update tests, & correct comments Dec 28, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@trekhleb
Copy link
Owner

trekhleb commented Jan 3, 2021

Thanks @austintheriot

@trekhleb trekhleb changed the base branch from master to merge January 3, 2021 09:25
@trekhleb trekhleb merged commit cf61af5 into trekhleb:merge Jan 3, 2021
@austintheriot austintheriot deleted the insertion-sort branch January 3, 2021 13:12
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.

None yet

2 participants