js-data-structures-algorithms
Advanced tools
Comparing version 1.1.0 to 1.1.2
@@ -19,22 +19,21 @@ function binarySearchRecursive(n, arr) { | ||
function binarySearch(n, list) { | ||
let minIndex = 0; | ||
let maxIndex = list.length - 1; | ||
function binarySearch(n, collection) { | ||
const not_found = -1; | ||
let currentIndex; | ||
let currentMidpoint; | ||
size = collection.length; | ||
left = 0; | ||
right = size - 1; | ||
while (minIndex <= maxIndex) { | ||
currentIndex = Math.floor((minIndex + maxIndex) / 2); | ||
currentMidpoint = list[currentIndex]; | ||
if (currentMidpoint < n) { | ||
minIndex = currentIndex + 1; | ||
} else if (currentMidpoint > n) { | ||
maxIndex = currentIndex - 1; | ||
while (left <= right) { | ||
midpoint = Math.floor((left + right) / 2); | ||
if (collection[midpoint] < n) { | ||
left = midpoint + 1; | ||
} else if (collection[midpoint] > n) { | ||
right = midpoint - 1; | ||
} else { | ||
return currentIndex; | ||
return midpoint; | ||
} | ||
} | ||
return -1; | ||
return not_found; | ||
} | ||
@@ -41,0 +40,0 @@ |
{ | ||
"name": "js-data-structures-algorithms", | ||
"description": "Project for showing different data structures and algorithms implemented in Javscript. Not exhaustive, mostly exploratory in nature and for career development. If you see anything wrong, let me know!", | ||
"version": "1.1.0", | ||
"version": "1.1.2", | ||
"main": "index.js", | ||
@@ -17,8 +17,3 @@ "scripts": { | ||
}, | ||
"keywords": [ | ||
"data", | ||
"structures", | ||
"algorithms", | ||
"javascript" | ||
], | ||
"keywords": ["data", "structures", "algorithms", "javascript"], | ||
"author": "Darren Jennings", | ||
@@ -40,10 +35,11 @@ "license": "MIT", | ||
}, | ||
"czConfig": { | ||
"path": "cz-conventional-changelog" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "cz-conventional-changelog" | ||
}, | ||
"ghooks": { | ||
"pre-commit": "yarn test" | ||
} | ||
} | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
# Data structures and Algorithms - Javascript | ||
[![Travis](https://img.shields.io/travis/darrenjennings/js-data-structures-algorithms.svg?style=flat-square)](https://travis-ci.org/darrenjennings/js-data-structures-algorithms) | ||
[![Coverage](https://img.shields.io/codecov/c/github/darrenjennings/js-data-structures-algorithms.svg?style=flat-square)](https://codecov.io/gh/darrenjennings/js-data-structures-algorithms) | ||
[![Coverage](https://img.shields.io/codecov/c/github/darrenjennings/js-data-structures-algorithms.svg?style=flat-square)](https://travis-ci.org/darrenjennings/js-data-structures-algorithms) | ||
[![Npm](https://img.shields.io/npm/v/js-data-structures-algorithms.svg?style=flat-square)](https://www.npmjs.com/package/js-data-structures-algorithms) | ||
@@ -6,0 +6,0 @@ [![MIT License](https://img.shields.io/npm/l/js-data-structures-algorithms.svg?style=flat-square)](https://www.npmjs.com/package/js-data-structures-algorithms) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
147706
12
276
1