Skip to content

Commit 17d192e

Browse files
committed
[Algorithm Design and Techniques]
1 parent 8e7d733 commit 17d192e

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ coverage
66
coverage.lcov
77
mochawesome-report/*
88
dist/js/*
9+
dist-/*
910
dist/ts/*
1011
snippet.js

src/js/algorithms/dynamic-programing/knapsack.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ function findValues(n, capacity, kS) {
44
// console.log('Items that are part of the solution:');
55
while (i > 0 && k > 0) {
66
if (kS[i][k] !== kS[i - 1][k]) {
7-
/*console.log(
8-
'item ' + i + ' can be part of solution w,v: ' + weights[i - 1] + ',' + values[i - 1]
9-
);*/
7+
//console.log(
8+
// 'item ' + i + ' can be part of solution w,v: ' + weights[i - 1] + ',' + values[i - 1]
9+
// );
1010
i--;
1111
k -= kS[i][k];
1212
} else {

src/js/algorithms/search/binary-search-recursive.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ function binarySearchRecursive(array, value, low, high, compareFn = defaultCompa
77
const element = array[mid];
88
if (compareFn(element, value) === Compare.LESS_THAN) {
99
return binarySearchRecursive(array, value, mid + 1, high, compareFn);
10-
} else if (compareFn(element, value) === Compare.BIGGER_THAN) {
10+
}
11+
if (compareFn(element, value) === Compare.BIGGER_THAN) {
1112
return binarySearchRecursive(array, value, low, mid - 1, compareFn);
12-
} else {
13-
return mid;
1413
}
14+
return mid;
1515
}
1616
return DOES_NOT_EXIST;
1717
}

0 commit comments

Comments
 (0)