The Basic-DSA-Algo
is a Node.js package that provides basic data structures and algorithms commonly used in computer science.
You can install Basic-DSA-Algo
using npm. Run the following command:
npm install basic-dsa-algo
📁Package |--- 📝Components |--- Linear Search |--- Binary Search |--- Bubble Sort |--- Insertion Sort | |--- so on ➡️ |--- index.js |--- package.json |--- LICENSE |--- README
// importing function
const { binarySearch } = require('basic-dsa-algo');
const arr = [1, 3, 5, 7, 9];
const target = 5;
const index = binarySearch(arr, target);
if (index !== -1) {
console.log(`Element ${target} found at index ${index}`);
} else {
console.log(`Element ${target} not found in the array`);
}
Element 5 found at index 2