Binary Search.
Installation
npm install @superiqbal7/binarysearch --save
Synopsis
Given a sorted array arr[] of n elements, search a given element x in arr[].:
const binarySearch = require("@superiqbal7/binarysearch");
binarySearch([1, 2, 3, 4], 4); // Prints '4'
binarySearch([1, 2, 3, 4], 5); // Prints '-1'
License
MIT