mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-07-06 17:44:08 +08:00
Fix the insertion sort (#86)
* Fix LinkedList * Fix the prepend method for the LinkedList * Fix the remove method for the MinHeap * Correct a comment * Fix BST removal method * Fix the findEdge method of the graph * Fix the value returned by DisjointSet union * Add recursive factorial function * Fix the insertion sort
This commit is contained in:

committed by
Oleksii Trekhleb

parent
e3b482c5e6
commit
d82958dea9
@ -14,7 +14,7 @@ export default class InsertionSort extends Sort {
|
||||
// Go and check if previous elements and greater then current one.
|
||||
// If this is the case then swap that elements.
|
||||
while (
|
||||
array[currentIndex - 1] &&
|
||||
array[currentIndex - 1] !== undefined &&
|
||||
this.comparator.lessThan(array[currentIndex], array[currentIndex - 1])
|
||||
) {
|
||||
// Call visiting callback.
|
||||
|
Reference in New Issue
Block a user