This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Binary search is a search algorithm that finds the position of a target value within a sorted array. | |
* Binary search has O(log n) complexity. | |
* @param {!Array} list The sorted array. | |
* @param {*} item The item to search. | |
* @return {number} Returns the index of the item in the array. | |
* @see https://en.wikipedia.org/wiki/Binary_search_algorithm | |
*/ | |
const binarySearch = (list, item) => { | |
let low = 0; |
OlderNewer