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

InsertionSort: use index to compare instead undefined #231

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

Conversation

SidKwok
Copy link
Contributor

@SidKwok SidKwok commented Oct 21, 2018

  1. use currentIndex - 1 >= 0 instead array[currentIndex - 1] !== undefined in while-loop, I think it should be more readable.
  2. swap value with destructuring assignment

some thoughts:
Since the for-loop in InsertionSort should start from 1(in 0 it will just pass the while-loop), I think for (let i = 1; i < array.length; i += 1) would be a better idea.

@codecov
Copy link

codecov bot commented Oct 21, 2018

Codecov Report

Merging #231 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #231   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         143    143           
  Lines        2554   2552    -2     
  Branches      422    422           
=====================================
- Hits         2554   2552    -2
Impacted Files Coverage Δ
...algorithms/sorting/insertion-sort/InsertionSort.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fad170c...f8a0ec8. Read the comment docs.

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

1 participant