JS Linear Search
Sequentially checks the target value in given list and match found.
Time Complexity:
best : O(1)
Worst: O(n)
Space Complexity: O(1)
function linearSearch(arr, target) {
for (let i in arr) {
if(arr[i] === target) return i;
...
·1 min read·vkglobal.hashnode.devRead the article
Saleh Mubashar
Nice post, Kindly check out mine too thanks