@ds-javascript/search
v1.0.0
Published
This is linear and binary search in javscript
Downloads
4
Maintainers
Readme
@ds-javascript/search
Usage
const Search = require('@ds-javascript/search');
const search = new Search()
API
.linear(array,element) It performs linear search on array and finds a given element. Returns index of element if found otherwise -1.
search.linear([34,51,1,2,3,45,56,687], 45)
.binary(array,element) It performs binary search on array and finds a given element. Returns index of element if found otherwise -1. Array needs to be in sorted order then only binary search will return valid result.
search.binary([1,2,3,34,45,51,56,687], 45)