Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

feat(algorithms): add merge sort for array of numbers #74

Merged
merged 1 commit into from
Jan 15, 2021

Conversation

jp-tran
Copy link
Contributor

@jp-tran jp-tran commented Jan 15, 2021

No description provided.

Copy link
Owner

@jeffzh4ng jeffzh4ng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few nits for the future. There should be space between variables declarations and operations.

Comment on lines +67 to +68
if (left >= right) return
const mid = Math.floor((left + right) / 2) // find middle index of current subarray
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

if(left >= right) return

const mid = Math.floor(...)

mergeSort()
mergeSort()
merge()

jest.clearAllMocks()
})

it('is raised when left or right indices are not integers', () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏆

let i = 0 // starting index of leftArr
let j = 0 // starting index of rightArr
let k = left // starting index of merged subarray (i.e. arr[left:right+1])
while (i < leftArr.length && j < rightArr.length) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

let k = left

while (...) {

}

@jeffzh4ng jeffzh4ng merged commit cdd093c into jeffzh4ng:master Jan 15, 2021
@github-actions
Copy link

🎉 This PR is included in version 2.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants