Implement linear and binary search algorithms with Javascript

Connor Leech
Employbl
Published in
2 min readDec 30, 2017

--

Software engineers use search algorithms to find elements and to sort through data. In this post we’re going to cover linear search and binary search for finding elements in a list.

If you are not familiar with data structures in Javascript I recommend checking out itsy-bitsy-data-structures by James Kyle.

Linear search

Linear search is the simplest and least performant searching algorithm we’ll cover. Literally, all it is is loop over the array until you find what you’re looking for. Below is a three minute video from Harvard that explains the linear search algorithm more thoroughly.

This will not likely be covered in interviews as it is the least performant. If you do write a loop that traverses an array and the interviewer asks…

--

--

Connor Leech
Employbl

Girl Dad x 2. Cofounder @Employbl. Software Engineer @CommentSold.