SIGN IN SIGN UP

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

0 0 332 JavaScript

optimized for loop & corrected comments (#617)

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.

Co-authored-by: Oleksii Trekhleb <trehleb@gmail.com>
A
Austin Theriot committed
cf61af59c532ad180fd9b65a21a11e88413e6ebc
Parent: 8124034
Committed by GitHub <noreply@github.com> on 1/3/2021, 9:26:14 AM