binary-search-pakage
v1.0.3
Published
Binary search algorithm
Downloads
2
Readme
Binary Search
This npm package provides a simple and efficient implementation of the binary search algorithm in JavaScript.
Installation
To install the package, use npm:
Usage
const binarySearch = require('@your_username/binary-search');
// Example usage: const array = [2, 4, 6, 8, 10, 12, 14, 16]; const target = 10; const result = binarySearch(array, target); console.log("Element found at index:", result);
API
binarySearch(arr, target)
This function takes an array arr and a target value target, and returns the index of the target value in the array if found, otherwise -1.
- arr: The array to be searched.
- target: The value to search for within the array.
npm install @your_username/binary-search