From d82958dea9d88e7a109b2babb9f317996ffe2fdf Mon Sep 17 00:00:00 2001 From: m-maksyutin Date: Tue, 3 Jul 2018 11:56:34 +0300 Subject: [PATCH] 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 --- src/algorithms/sorting/insertion-sort/InsertionSort.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/sorting/insertion-sort/InsertionSort.js b/src/algorithms/sorting/insertion-sort/InsertionSort.js index 330a2e66..615f3652 100644 --- a/src/algorithms/sorting/insertion-sort/InsertionSort.js +++ b/src/algorithms/sorting/insertion-sort/InsertionSort.js @@ -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.