npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

binary-search-variations

v2.0.4

Published

This consists of variations of several binary search functions used

Downloads

4

Readme

binary-search-variations

Don't want to write lengthy binary search algorithms in your code? Then this package is for you. binary-search-variations is an npm package that contains all important variations of the binary search algorithm, which you can implement in your code with just one line of code.

Read the documentation below to know more about the package.

Installation

npm i binary-search-variations

Usage

const { findGreatestLess } = 'binary-search-variations'

const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
const target = 5

const index = findGreatestLess(arr, target)
console.log(index) // 4

The functionalities included in this package -

  • typea a. Normal Binary Search(normalBinarySearch): This is the normal binary search algorithm which returns the index of the element if found, else returns -1.

    b. Find Lower Bound(findLowerBound): This function returns the index of the first element which is greater than or equal to the given element. If no such element is found, it returns -1.

    c. Find Upper Bound(findUpperBound): This function returns the index of the first element which is greater than the given element. If no such element is found, it returns -1.

    d. Find Least Greater(findLeastGreater): This function returns the index of the least element which is greater than the given element. If no such element is found, it returns -1.

    e. Find Greatest Lesser(findGreatestLesser): This function returns the index of the greatest element which is lesser than the given element. If no such element is found, it returns -1.

  • typeb: a. Find First and Last Occurence in an Array(searchTargetRange): This function returns the first and last occurence of the target element in the array. If the target element is not present in the array, it returns [-1, -1].

    b. Find Median of Two Arrays(medianOfArrays): This function returns the median of two sorted arrays.

    c. Search in 2D Matrix(search2DArr): It will return true if the target element is present in the 2D matrix, else it will return false.

    d. Find Peak Element(findPeakElement): This function returns the index of the peak element in the array. A peak element is an element which is greater than its neighbours.

  • typec: a. Find Missing Number(findMisingNumber): This function returns the missing number in the array. The array should contain numbers from 1 to n, with one number missing.