Skip to content

kanow-algorithms/binary-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

binary-search

Instalation

After you clone this repo you need to move inside binary-search directory and run command

npm install

To run npm install you must have installed node.js

Description

Binary search works only for sorted arrays

Example input :

const testArray: number = [31, 32, 44, 56, 61, 76];
binarySearch(testArray, 44);

Output of example input :

This method will return index of founded value. If value does not exist in this array method will return -1

2

binarySearch method takes two parametrs:

  • array -> it is the list of elements in which you want to find a value
  • value -> value to search

How it works

On this graphic you can see how binary-search algortihm works :

BinarySearch

Releases

No releases published

Packages

No packages published