@superiqbal7/binarysearch
v1.0.0
Published
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
Downloads
8
Maintainers
Readme
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