JavaScript Searching Algorithms
Medium
2
46.4% Acceptance
In this lab, you will learn and implement two popular searching algorithms - Linear Search and Binary Search. Your task is to create two functions named linearSearch
and binarySearch
in the index.js
file. The linearSearch
function should take an array and a search key as input, then return the index of the key if found within the array, otherwise it should return -1. The binarySearch
function should take a sorted array and a search key as input, then return the index of the key if found within the array, otherwise it should return -1. Make sure to export both functions using ESM syntax.