1.0.0 • Published 4 years ago

@ds-javascript/search v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@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)