Binary search is a searching algorithm that works on sorted data. Binary searches check the middle value to see whether the desired value is greater or smaller than it. If the desired value is smaller, this algorithm can search the smaller parts, or it ca
npm install @superiqbal7/binarysearchnpm install @superiqbal7/binarysearch --save
Given a sorted array arr[] of n elements, search a given element x in arr[].:
``javascript
const binarySearch = require("@superiqbal7/binarysearch");
binarySearch([1, 2, 3, 4], 4); // Prints '4'
binarySearch([1, 2, 3, 4], 5); // Prints '-1'
``
MIT